home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 2 / ACE CD 2.iso / FILES / DOCS / AMOSDOC.LHA / AmosPart2.doc < prev    next >
Encoding:
Text File  |  1994-11-27  |  131.9 KB  |  3,768 lines

  1. 5: STRING FUNCTIONS
  2.  
  3.         =LEFT$= (return the leftmost characters of a string)
  4.  
  5. d$=LEFT$(s$,n)
  6.  
  7. This instruction works like in nearly any Basic language (for example,
  8. AmigaBasic). Example:
  9.  
  10.         B$="Hello! This is Ronnie!"
  11.         L$=Left$(B$,9)
  12.         Print L$
  13. ( result: Hello! Th )
  14.  
  15.          =RIGHT$= (return the rightmost character of a string)
  16.  
  17. d$=RIGHT$(s$,n)
  18.  
  19. Same as the LEFT$ -instruction, but takes the rightmost characters.
  20.  
  21.         Print Right$("AMOS Basic",5)
  22. ( result: Basic )
  23.  
  24.       =MID$= (return a string of characters from within a string)
  25.  
  26. d$=MID$(s$,p,n)
  27. MID$(d$,p,n)=s$
  28.  
  29. The MID$ function returns the middle section of the string held in s$.
  30. p denotes the offset of characters to the start of this substring, and
  31. n holds the number of characters to be fetched. If a value of "n" is
  32. not specified in the instruction then the characters will be read right
  33. up to the end of your string. Example:
  34.  
  35.         Print Mid$("AMOS Basic",6)
  36. ( result: Basic )
  37.  
  38. There is also a MID$ instruction:
  39.  
  40.         MID$(d$,p,n)=s$
  41.  
  42. This version of MID$ loads "n" characters into d$ starting from
  43. position p+1 in s$. If a value of n is not specified directly then
  44. characters will be replaced up to the end of the source string s$. This
  45. kind of instruction is also possible when using LEFT$ and RIGHT$.
  46. Here's an example:
  47.  
  48.         A$="AMOS *****"
  49.         Mid$(A$,5)="Magic"
  50.         Print A$
  51. ( result: AMOS Magic )
  52.  
  53.                  =INSTR (search for occurrences of a
  54.                      string within another string)
  55.  
  56. f=INSTR(d$,s$ [,p])
  57.  
  58. INSTR allows you to search for all occurrences of one string inside
  59. another. It is often used in adventure games to split a complete line
  60. of text into its individual commands. There are two possible formats of
  61. the INSTR function.
  62.  
  63. f=INSTR(d$,s$)
  64.  
  65. This searches for the first occurrence of s$ in d$. If the string is
  66. found then its position will be returned directly, otherwise the result
  67. will be set to zero. Examples:
  68.  
  69.         Print Instr("AMOS BASIC","AMOS")
  70. ( result: 1 )
  71.         Print Instr("AMOS BASIC","S")
  72. ( result: 4 )
  73.         Print Instr("AMOS BASIC","AMIGA")
  74. ( result: 0 )
  75.  
  76.         Do
  77.           Input "String to be searched";D$
  78.           Input "String to be found";S$
  79.           X=Instr(D$,S$)
  80.           If X=0 Then Print S$;" Not found"
  81.           If X<>0 Then Print S$;" Found at position ";X
  82.         Loop
  83.  
  84. Normally the search will commence from the first character in your text
  85. string (d$). The secont version of INSTR lets you test a specific
  86. section in the string at a time.
  87.  
  88.   p is now the position of the beginning of your search. All characters
  89. are numbered from the left to right starting from zero. Therefore p
  90. ranges from 0 to LEN(s$). Example:
  91.  
  92.         Print Instr("AMOS BASIC","S",5)
  93. ( result: 8)
  94.  
  95.           =UPPER$ (convert a string of text to upper case)
  96.  
  97. s$=UPPER$(n$)
  98.  
  99. This function converts the string in n$ into upper case (capitals) and
  100. places the result into s$. Example:
  101.  
  102.         Print Upper$("AmOs BaSic")
  103. ( result: AMOS BASIC )
  104.  
  105.                =LOWER$ (convert a string to lower case)
  106.  
  107. s$=LOWER$(n$)
  108.  
  109. LOWER$ translates all the characters in n$ into lower case. This is
  110. especially useful in adventure games, as you can convert all the user's
  111. input into a standard format which is much easier to interpret.
  112. Example:
  113.  
  114.         Input "Continue (Yes/No)";ANSWER$
  115.         ANSWER$=Lower$(ANSWER$) : If ANSWER$="no" Then Edit
  116.         Print "Continuing with your prog..."
  117.  
  118.                        =FLIP$ (invert a string)
  119.  
  120. f$=FLIP$(n$)
  121.  
  122. FLIP$ simply reverses the order of the characters held in n$.
  123.  
  124.                      =SPACE$ (space out a string)
  125.  
  126. s$=SPACE$(n)
  127.  
  128. Generates a string of n spaces and places them into s$. Example:
  129.  
  130.         Print "Twenty" ; Space$(20); "spaces"
  131.  
  132.                  =STRING$ (create a string full of a$)
  133.  
  134. s$=STRING$(a$,n)
  135.  
  136. STRING$ returns a string with n copies of the first character in a$:
  137.  
  138.         Print String$("The cat sat on the mat",10)
  139. ( result: TTTTTTTTTT )
  140.  
  141.                     =CHR$ (return Ascii character)
  142.  
  143. s$=CHR$(n)
  144.  
  145. Creates a string containing a single character with Ascii code n.
  146.  
  147.                  =ASC (get Ascii code of a character)
  148.  
  149. c=ASC(a$)
  150.  
  151. ASC supplies you with the internal Ascii code of the first character in
  152. the string a$:
  153.  
  154.         Print Asc("B")
  155. ( result: 66 )
  156.  
  157.          =LEN (returns the number of characters stored in a$)
  158.  
  159. This way you can get the length of a string:
  160.  
  161.         Print Len("12345678")
  162. ( result: 8 )
  163.  
  164.                    =VAL (convert a string to number)
  165.  
  166. v=VAL(x$)
  167. v#=VAL(x$)
  168.  
  169. VAL converts a list of decimal digits stored in x$ into a number. If
  170. this process fails for some reason, a value of zero will be returned
  171. instead. Example:
  172.  
  173.         X=Val("1234):Print X
  174. ( result: 1234 )
  175.  
  176.                  =STR$ (convert a number to a string)
  177.  
  178. s$=STR$(n)
  179.  
  180. STR$ converts an integer variable into a string. This can be very
  181. useful because some functions, such as CENTRE, do not allow you to
  182. enter numbers as a parameter. Example:
  183.  
  184.         Centre "Memory left is "+Str$(Chip Free)+" Bytes."
  185.  
  186. Do not confuse STR$ with STRING$.
  187.  
  188. Array options
  189.  
  190.                  SORT (sort all elements in an array)
  191.  
  192. SORT a(0)
  193. SORT a#(0)         The SORT instruction arranges the contents of any
  194. SORT a$(0)         array into ascending order. This array can contain
  195.                    either strings, integers, or floating point numbers.
  196. The a$(0) parameter specifies the starting point of your table. It must
  197. always be set to the first item in the array (item number 0). Example:
  198.  
  199.         Dim A(25)
  200.         P=0
  201.         Repeat
  202.           Input "Input a number (0 to stop)";A(P)
  203.           Inc P
  204.         Until A(P-1)=0 Or P>25
  205.         Sort A(0)
  206.         For I=0 to P-1
  207.           Print A(I)
  208.         Next
  209.  
  210.                         MATCH (search an array)
  211.  
  212. r=MATCH(t(0),s)
  213. r=MATCH(t#(0),s#)     MATCH searches through a sorted array for the
  214. r=MATCH(t$(0),s$)     value s. If this is succesfully found then r
  215.                       will be negative. Taking the absolute value of
  216. this figure will provide you with the item which came closest to your
  217. original search parameter.
  218.  
  219.   Note that only arrays with a single dimension can be checked in this
  220. way. You'll also need to sort the array with SORT before calling this
  221. function. Example:
  222.  
  223.         Read N
  224.         Dim D$(N)
  225.         For I=1 to N
  226.           Read D$(I)
  227.         Next I
  228.         Sort D$(0)
  229.         Do
  230.           Input A$
  231.           If A$="L"
  232.             For I=1 to N:Print D$(I):Next I
  233.           Else
  234.             POS=Match(D$(0),A$)
  235.             If POS>0 Then Print "Found",D$(POS);" In Record ";POS
  236.             If POS<0 And Abs(POS)<=N Then Print A$,"Not Found. Closest
  237.                                                      To ",D$(Abs(POS))
  238.             If POS<0 And Abs(POS)>N Then Print A$, "Not Found. Closest
  239.                                                             To ";D$(N)
  240.           Endif
  241.         Loop
  242.         Data 10,"Adams","Asimov","Shaw","Heinlien","Zelazny","Foster"
  243.         Data "Niven","Harrison","Pratchet","Dickson"
  244.  
  245. Note that MATCH could be used in conjunction with the INSTR function to
  246. provide a powerful parser routine. This might be used to interpret the
  247. instructions you entered in an adventure game.
  248.  
  249. 6:GRAPHICS
  250. AMOS Basic provides you with everything you need to generate some
  251. amazing graphics. There's a comprehensive set of commands for drawing
  252. rectangles, circles and polygons. As you would expect from the Amiga,
  253. all operations are performed practically instantaneously. But even here
  254. AMOS Basic has a trick or two up its sleeve.
  255.  
  256.   The AMOS graphical functions work equally well in all the Amiga's
  257. graphics modes INCLUDING hold and modify mode (HAM). It's therefore
  258. possible to create breathtaking HAM pictures directly within AMOS
  259. Basic!
  260.  
  261.   Furthermore, you're not just limited to the visible screen. If you've
  262. created an extra large playing area, you'll be able to access every
  263. part of your display using the standard drawing routines. So it's easy
  264. to generate the scrolling backgrounds required by arcade games such as
  265. Defender.
  266.  
  267. Colours
  268. The Amiga allows you to display up to 64 colours on the screen at a
  269. time. These colours can be selected using the INK,COLOUR and PALETTE
  270. commands.
  271.  
  272.               INK (set colour used by drawing operations)
  273.  
  274. INK col[,paper][,border]
  275.  
  276. "col" specifies the colour which is to be used for all subsequent
  277. drawing operations. The colour of every point on the screen is taken
  278. from one of 32 different colour registers. These registers can be
  279. individually set with a colour value chosen from a palette of 4096
  280. colours.
  281.  
  282.   Although the Amiga only provides you with 32 actual color registers,
  283. AMOS lets you use colour numbers ranging from 0 to 63. This allows you
  284. to make full use of the colours available from the Half-Bright and HAM
  285. modes respectively. A detailed explanation of these modes can be found
  286. in the Screens chapter.
  287.  
  288.   The "paper" colour sets the background colour fill patterns generated
  289. by the SET PATTERN command.
  290.  
  291.   The "border" colour selects an outline colour for your bars and
  292. polygons. This option can be activated using the SET PAINT command like
  293. so:
  294.  
  295.         Set pattern 0 : Set paint 1
  296.         Repeat
  297.           C=Rnd(16):Ink 16-C,0,C
  298.           X=Rnd(320)-20:Y=Rnd(200)-20:S=Rnd(100)+10
  299.           Bar X,Y to X+S,Y+S
  300.         Until Mouse Key
  301.  
  302. Note that any of the parameters col, paper and border, may be omitted.
  303. Simply include "empty" commas at the appropriate places in the
  304. instruction. For example:
  305.  
  306.         Ink ,,5 : Rem  Just sets the border colour
  307.  
  308.                   COLOUR (assign a colour to an index)
  309.  
  310. COLOUR index,$RGB
  311.  
  312. The COLOUR instruction allows to assign a colour to each of the Amiga's
  313. 32 colour registers.
  314.  
  315.   "Index" is the number of the colour you wish to change, and can range
  316. from 0-31. As you may know, any colour can be created by mixing
  317. specific amounts of the primary colours Red, Green and Blue. The shade
  318. of your colour is completely determined by the relative intensities of
  319. the three components
  320.  
  321.   The expression $RGB consists of three digits from 0 to F. Each
  322. component sets the strength of one of the primary colours, Red (R),
  323. Green (G) or Blue (B). The size of the components is directly
  324. proportional to the brightness of the associated colour. So the higher
  325. values, the brighter the eventual colour.
  326.  
  327.         Hex Digit   0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
  328.         Decimal     0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15
  329.  
  330. HAM and Extra Half-Bright modes use these indices slighty differently.
  331. See Chapter 9 for more details.
  332.  
  333.                  =COLOUR (read the colour assignment)
  334.  
  335. c=COLOUR(index)
  336.  
  337. The COLOUR function takes an index number from 0 to 31, and returns the
  338. coour value which has been previously assigned to it.
  339.   "Index" is simply the colour number whose shade you wish to
  340. determine. You can use this function to produce a list of the current
  341. colour settings of your Amiga like so:
  342.  
  343.         For C=0 To 15
  344.           Print Hex$(Colour(C),3)
  345.         Next C
  346.  
  347.                PALETTE (set the current screen colours)
  348.  
  349. PALETTE list of colours
  350.  
  351. The PALETTE instruction is really just a rather more powerful version
  352. of COLOUR. Instead of loading the colour values one at a time, the
  353. PALETTE command allows you to install a whole new palette of colours in
  354. a single statement.
  355.  
  356.         However you don't have to set all the colours in the palette at
  357. once. Any combination of colours can be loaded individually ;
  358.  
  359.         PALETTE $100,$200,$300 : Rem Sets just three colours
  360.  
  361. You can also change selected colours in the middle of your list ;
  362.  
  363.         PALETTE $200,,$400 : Rem Change colours 0 and 2
  364.  
  365. It's important to realise that only the colours in the palette which
  366. are specifically set by this command will actually be changed. All
  367. other colours will retain their original values. Here are some
  368. examples:
  369.  
  370.         Palette 0,$F00,$0F0
  371.         Palette 0,$770
  372.         Palette 0,,$66
  373.         Palette 0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$A,$B,$C,$D,$E,$F
  374.  
  375. At the start of your program the colour palette is automatically loaded
  376. using a list of default color values. These settings can be adjusted
  377. using a simple option from the AMOS configuration program.
  378.  
  379.   This command can also be used to set the colours used by the
  380. Half-Bright and HAM modes. These extend the existing colour palette to
  381. generate dozends of extra colours on the screen. See chapter 10...
  382.  
  383. Line drawing commands
  384.  
  385.                  GR LOCATE (position graphics cursor)
  386.  
  387. GR Locate x,y
  388.  
  389. This sets the position of the graphics cursor to screen coordinates
  390. x,y. The graphics cursor is used as the default starting point for most
  391. drawing operations. So if you omit the coordinates from commands such
  392. as PLOT or CIRCLE, the objects will be drawn at the current cursor
  393. position. For example:
  394.  
  395.         Gr Locate 10,10 : Plot ,
  396.         Gr Locate 100,100 : Circle ,,100
  397.  
  398.  
  399.  
  400.                =XGR (return x coordinate of gfx cursor)
  401.                =YGR (return y coordinate of gfx cursor)
  402.  
  403. x=XGR
  404. y=YGR
  405.  
  406. These functions return the present coordinates of the graphics cursor:
  407.  
  408.         Circle 10,100,100
  409.         Print Xgr,Ygr
  410.  
  411.  
  412.                       PLOT (plot a single point)
  413.  
  414. PLOT x,y [,c]
  415.  
  416. The PLOT command is the simplest drawing function provided by AMOS
  417. Basic. It plots a point at coordinates x,y using colour c. The new ink
  418. colour will now be used in all subsequent drawing operations.
  419.  
  420.   If the colour "c" is omitted from this instruction, the point will be
  421. plotted in the current colour. For example:
  422.  
  423.         Curs Off: Flash Off : Randomize Timer
  424.         Do
  425.           Plot Rnd(319),Rnd(199),Rnd(15)
  426.         Loop
  427.  
  428. It's also possible to omit the X or Y coordinates from this
  429. instruction. The point will be plotted at the gfx cursor position.
  430.  
  431.         Plot 100,100,4
  432.         Plot ,150
  433.         Cls : Plot ,
  434.  
  435.  
  436.                    POINT (get the colour of a point)
  437.  
  438. c=POINT(x,y)
  439.  
  440. POINT returns the colour index of a point at coordinates x,y ;
  441.  
  442.         Plot 100,100
  443.         Print "The colour at 100,100 is ";Point(100,100)
  444.  
  445.                           DRAW (draw a line)6
  446.  
  447. DRAW is another very Basic instruction. Its action to draw a simple
  448. straight line on the Amiga's screen.
  449.  
  450.         DRAW x1,y1 TO x2,y2
  451.  
  452. Draws a line between the coordinates x1,y1 and x2,y2
  453.  
  454.         DRAW TO x3,y3
  455.  
  456. Draw a line from the current gfx crsr position to x3,y3. Example:
  457.  
  458.         Colour 4,$707:Ink 4
  459.         Draw 0,50 To 200,50
  460.         Draw To 100,100
  461.         Draw To 0,50
  462.  
  463.                      BOX (draw a hollow retangle)
  464.  
  465. BOX x1,y1 TO x2,y2
  466.  
  467. The BOX command draws a hollow retangular box on the screen. x1,y1 are
  468. the coordinates of the top left corner of the box, and x2,y2 are the
  469. coordinates of the point diagonally opposite.
  470.  
  471.  
  472.                    POLYLINE (multiple line drawing)
  473.  
  474. POLYLINE is very similar to DRAW except that it draws several lines at
  475. a time. It's capable of generating complex hollow polygons in just a
  476. single statement.
  477.  
  478.         POLYLINE x1,y1 TO x2,y2 TO x3,y3
  479.  
  480.  
  481.                      CIRCLE (draw a hollow circle)
  482.  
  483. CIRCLE x,y,r
  484.  
  485. The Circle command draws a hollow circle with radius r and centre x,y.
  486.  
  487. As normal, if the coordinates are omitted from this command, the circle
  488. will be drawn from the current cursor position;
  489.  
  490.         Plot 100,100 : Circle ,,50
  491.  
  492.  
  493.                     ELLIPSE (draw a hollow ellipse)
  494.  
  495. ELLIPSE x,y,r1,r2
  496.  
  497. The ELLIPSE instruction draws a hollow ellipse at coordinates x,y. The
  498. horizontal radius is r1. It corresponds to exactly half the width of
  499. the ellipse. r2 is the vertical radius and is used to set the height of
  500. the ellipse. The total height of the ellipse is r*2
  501.  
  502. Line types
  503. AMOS Basic allows you to draw your lines using a vast range of possible
  504. line styles.
  505.  
  506.                     SET LINE (set the line styles)
  507.  
  508. SET LINE mask
  509.  
  510. The SET LINE command sets the style of all lines which are subsequently
  511. drawn using the DRAW, BOX and POLYLINE commands.
  512.  
  513.   "Mask" is a 16-bit binary number which describes the precise
  514. appearance of the line. Any points in the line which are to be
  515. displayed in the current ink colour are represented by a one, and any
  516. points which are to be set to the background colour are indicated by a
  517. zero. So a normal line is denoted by the binary number
  518. %1111111111111111 and will be displayed as _______. Similarly, a dotted
  519. line like _ _ _ _ will be produced by a mask of %1111000011110000.
  520.  
  521.   By setting the line mask to values between 0 and 65535, it is
  522. possible to generate a great variety of different line types ;
  523.  
  524.         Set Line $F0F0
  525.         Box 50,100 To 150,150
  526.  
  527. This line style as no effect on shapes drawn with CIRCLE or ELLIPSE.
  528.  
  529. Filled shapes
  530.  
  531.                          PAINT (contour fill)
  532.  
  533. PAINT x,y,mode
  534.  
  535. The PAINT command allows you to fill any region on the screen with a
  536. solid block of colour. Additionally you can select a fill pattern for
  537. your shapes using the SET PATTERN command.
  538.  
  539.   x,y are the coordinates of a point inside the area to be filled.
  540. "Mode" can be set to either 0 or 1. A value of 0 terminates the filling
  541. operation at the first pixel found with the current border colour. A
  542. mode of 1 halts the filling operation at any colour which is different
  543. from the existing ink colour.
  544.  
  545. See EXAMPLE 6.1  in the MANUAL folder for a demonstration.
  546.  
  547.                      BAR (draw a filled rectangle)
  548.  
  549. BAR x1,y1 TO x2,y2
  550.  
  551. Draws a filled bar from x1,y1 -the coordinates of the top left corner
  552. of the bar- to x2,y2 -the opposite corner coordinates.
  553.  
  554.                     POLYGON (draw a filled polygon)
  555.  
  556. POLYGON x1, TO x2,y2 TO x3,y3 ...
  557. POLYGON TO x1,y1 TO x2,y2 ...
  558.  
  559. POLYGON generates a filled polygon in the current ink colour It's
  560. basically just a solid version of the standard POLYLINE command.
  561. There's no real limit to the number of coordnate pairs you may use,
  562. other than the maximum line length permitted by AMOS Basic (255 chars).
  563.  
  564. Fill types
  565. In AMOS Basic you're not just restricted to filling your shapes with a
  566. solid block of colour. There are dozens of fill patterns to choose
  567. from, and you can even load your own patterns directly from the sprite
  568. bank.
  569.  
  570.                    SET PATTERN (select fill pattern)
  571.  
  572. SET PATTERN pattern
  573.  
  574. This command allows you to select a fill pattern for use by your
  575. drawing operations. There are three possibilities
  576.  
  577.         Pattern=0
  578.  
  579. This is the default, and fills your shapes with a solid block of the
  580. current INK colour.
  581.  
  582.         Pattern>0
  583.  
  584. If the pattern number is >0, AMOS Basic selects on of 34 built-in fill
  585. styles. These are found in the MOUSE.ABK file on your start-up disc,
  586. and can be edited using the AMOS Basic sprite definer. Note that the
  587. first three images in this files are required by the mouse cursor (see
  588. CHANGE MOUSE). The fill patterns are stored in the images from four
  589. onwards.
  590.  
  591.         Pattern<0
  592.  
  593. This is the most powerful option of all. "Pattern" now refers to a
  594. sprite image in bank one. The image is number calculated using the
  595. formula:  SPRITE IMAGE = PATTERN * (-1)
  596.  
  597. The selected image will be automatically truncated before use,
  598. according to the following rules
  599.  
  600.  * The width of the image will be clipped to sixteen pixels
  601.  * The height will be rounded to the nearest power of two, ie 1,2..,64
  602.  
  603. Depending on the type of your image, the pattern will be drawn in one
  604. of two separate ways. Two-colour images are drawn in "monochrome". The
  605. actual colours in your image are completely discarded, and the pattern
  606. is drawn using the current ink and paper colours.
  607.  
  608.   It's also possible to produce multi-coloured fill patterns. In this
  609. case the foreground colours of your image and merged with the current
  610. ink colour using a logical AND. Similarly the paper colours of your
  611. pattern is OR'ed with the sprite background (colour zero). If you wish
  612. to use your original sprite colours, you'll need to set the ink and
  613. background colours like so:
  614.  
  615.         Ink 31,0
  616.  
  617. Don't forget to load your sprite palette from the sprite bank with
  618. GET SPRITE PALETTE before using these instructions, otherwise the
  619. display is likely to look rather messy. Examples of this instruction
  620. can be found in EXAMPLE 6.2  in the MANUAL folder.
  621.  
  622.                  SET PAINT (set / reset outline mode)
  623.  
  624. SET PAINT n
  625.  
  626. Toggles the outline drawn by the POLYGON or BAR instructions. As a
  627. default this mode is set to OFF.
  628.  
  629.   If n=1 then outline mode will be activated.
  630.  
  631. Writing styes
  632.  
  633.                    GR WRITING (ghange writing mode)
  634.  
  635. GR WRITING bitpattern
  636.  
  637. Whenever you draw some graphics on the screen, you naturally assume
  638. that anything underneath it will be overwriteen. The GR WRITING command
  639. allows you to choose from a range of four alternative drawing modes.
  640. These can used to generate dozens of intriguing effects.
  641.  
  642.   "Bitpattern" holds a sequence of binary bits which specify which
  643. graphics mode you wish to use. Here's a list of the various
  644. possibilities along with a brief explanation of their effects:
  645.  
  646. JAM1 mode (Bit 0=0)
  647.                     JAM1 only draws the parts of your graphics which
  648. are set to the current INK colour. Any sections drawn in the paper
  649. colour are totally omitted. This is particularly useful with with the
  650. TEXT command as it allows you to merge your text directly over an
  651. existing screen background. For example:
  652.  
  653.         Ink 2,5:Text 140,80,"Normal Text":Gr Writing 0:
  654.                                      Text 140,71,"JAM1"
  655.  
  656. JAM2 mode (Bit 0=1)
  657.                     This is the default condition. Any existing
  658. graphics on the screen will be completely replaced by your new image.
  659.  
  660.  
  661. XOR mode (Bit 1=1)
  662.                     XOR combines your new graphics with those already
  663. on the screen using a logical operation known as eXclusive OR. The net
  664. result is to change the colour of the areas of a drawing which overlap
  665. an existing picture.
  666.  
  667.   One interesting side effect of XOR mode is that you can erase any
  668. object from the screen by simply setting XOR mode and drawing your
  669. object again at exactly the same position. EXAMPLE 6.3  contains a
  670. simple demonstration of this technique and produces a neat rubber and
  671. banding effect.
  672.  
  673. INVERSEVID (Bit 2=1)
  674.                      This reverses the image before it is drawn. So any
  675. sections of your image drawn in the ink colour will be replaced by the
  676. current paper colour and vice-versa. INVERSEVID mode is often used to
  677. produce inverted text.
  678.  
  679.   Since these modes are set using a bitpattern, it's possible to
  680. combine several mode together.
  681.  
  682.         Gr Writing 4+1 : Rem set JAM2 and INVERSEVID
  683.         Gr Writing 7   : Rem chooses JAM2,INVERSEVID and XOR
  684.         Ink 2,5 : Text 140,80,"Accession & Image rulez!"
  685.  
  686. NOTE: This command only affects drawing operations such as CIRCLE, BOX
  687. and graphical text (TEXT). The drawing mode used by normal text
  688. commands like PRINT and CENTRE is set using a separate WRITING command.
  689. See also AUTOBACK.
  690.  
  691.           CLIP (restrict all gfx to a section of the screen)
  692.  
  693. CLIP [x1,y1 TO x2,y2]
  694.  
  695. The CLIP instruction limits all drawing operations to a rectangular
  696. region of the screen specified by the coordinates x1,y1 to x2,y2.
  697.  
  698.   x1,y1 represent the coordinates of the top left hand corner of the
  699. rectangle, and x2,y2 hold the coordinates of the bottom right corner.
  700.  
  701.   Note that it's perfectly acceptable to use coordinates outside the
  702. normal screen boundaries. All the clipping operations will work as
  703. expected, even if only a section of the clipping rectangle is actually
  704. visible.
  705.  
  706.   As you can see, only the parts of the circle which lie within the
  707. clipping rectangle have been drawn on the screen. The clipping zone can
  708. be restored to the normal screen area. by omitting all the coordinates
  709. from this instruction.
  710.  
  711.   See EXAMPLE 6.4  in the MANUAL folder.
  712.  
  713. Advanced techniques
  714.  
  715.                   SET TEMPRAS (set temporary raster)
  716.  
  717. SET TEMPRAS [address,size]
  718.  
  719. This instruction allows experienced Amiga programmers to fine tune the
  720. amount of memory used by various graphics operations. WARNING:
  721. improper use of this instruction can crash your Amiga copletely!
  722.  
  723.   Whenever an AMOS program performs a fill command, a special memory
  724. area is reserved to hold the fill pattern. This memory is automatically
  725. returned to the system after the instruction has been terminated. The
  726. size of the memory buffer is equivalent to a single bit plane in the
  727. current screen mode. So the default screen takes up to a total of 8k.
  728.  
  729.   The size and location of the graphics buffer can be changed at any
  730. time using the SET TEMPRAS instruction.
  731.  
  732.   "Size" is the number of bytes you wish to reserve for your buffer
  733. area. It ranges between 256 and 65536.
  734.  
  735.   The amount of memory required for a particular object can be
  736. calculated in the following way:
  737.  
  738.         - Enclose the object to be drawn with a rectangular box
  739.         - The area required will given by: Size=Width/8 * Height.
  740.  
  741. If you are intending to use the PAINT command, you should take care to
  742. ensure that your figure is *closed*, otherwise more memory will be
  743. neede and the system may crash.
  744.  
  745.   "Buffer" can be either an addess or a memory bank. The memory you
  746. reserve for this buffer should always be CHIP ram. Since the buffer
  747. area is now allocated once and for all at the start of your program,
  748. there's no need to continually reserve and restore the memory buffer.
  749. This can speed up the execution of your programs by up to 5 %.
  750.  
  751.   You can restore the buffer area to its original value by calling the
  752. SET TEMPRAS command with no parameters.
  753.  
  754.   See the EXAMPLE 6.5  in the MANUAL folder.
  755.  
  756. 7:CONTROL STRUCTURES
  757.  
  758.                    GOTO (jump to a new line number)
  759.  
  760. The action of GOTO is to transfer the control of the program one place
  761. to another. There are three forms of the GOTO command allowes in AMOS;
  762.  
  763.         GOTO label
  764.  
  765. "label" is an optional place marker at the side of a line. Label names
  766. are defined using the ":" colon character like so:
  767.  
  768.         label:
  769.  
  770. The label name can consist of any string of alphanumeric characters you
  771. like, including "-". It's constructed using the same rules which apply
  772. for variables and procedure names.
  773.  
  774.         GOTO line number
  775.  
  776. Any AMOS Basic line can be optionally preceded with a number. These
  777. line numbers are included solely for compatibility purposes with other
  778. versions of Basic (such as STOS for the Atari ST). It's better to rely
  779. on labels instead, as these are much easier to read and remember.
  780.  
  781.         GOTO variable
  782.  
  783. Variable can be any allowable AMOS Basic expression. This expression
  784. may be either a normal ingerer or a string. Integers run a line number
  785. for your GOTO, whereas strings hold the name of a label.
  786.  
  787.   Technically speaking, this construction is known as a computed goto.
  788. It's generally growned upon by serious programmers, but it can be
  789. incredibly useful at times. Examples:
  790.  
  791.         ROOM=3
  792.         BEGIN:
  793.         Goto "ROOM"+Str$(ROOM)-" "
  794.         End
  795.         ROOM3:
  796.         Print "Room three!"
  797.         Goto BEGIN
  798.  
  799.                      GOSUB (jump to a subroutine)
  800.  
  801. GOSUB is another outmoded instruction, and provides you with the useful
  802. ability to split a program into smaller, more manageable chunks, known
  803. as subroutines. Nowadays, GOSUB has been almost entirely supplanted by
  804. AMOS Basic's procedure system. However, GOSUB does form a useful
  805. half-way house when you're converting programs from another version of
  806. Basic such as STOS.
  807.  
  808.   As with GOTO, there are three different forms of the GOSUB
  809. instruction.
  810.  
  811.         GOSUB n         Jump to the subroutine at line n
  812.  
  813.         GOSUB name      Jump to an AMOS label
  814.  
  815.         GOSUB exp       Jump to a label or line which results from the
  816.                         expression in "exp".
  817.  
  818.         Example:
  819.  
  820.         For I=1 To 10
  821.           Gosub TEST
  822.         Next I
  823.         Direct
  824.         TEST:
  825.         Print "This is an example of GOSUB":Print "I equals ";I
  826.         Return: Rem Exit from subroutine TEST and return to main prg.
  827.  
  828. It's good practice to always plave your subroutines at the end of your
  829. main program as this makes them easier to pick out from your program
  830. listings. You should also add a statement like EDIT or DIRECT to end of
  831. your main program, as otherwise AMOS may attempt to execute your GOSUBs
  832. after the program has finished, generating an error message.
  833.  
  834.                    RETURN (return from a subroutine)
  835.  
  836. RETURN
  837.  
  838. RETURN exits from a subroutine which was previously entered using
  839. GOSUB. It immediately jumps back to the next Basic instruction after
  840. the original GOSUB.
  841.  
  842.   Note that a single GOSUB statement can contain several RETURN
  843. commands. So you can exit from any number of different points in your
  844. routine depending on the situation.
  845.  
  846.               POP (remove the RETURN info after a GOSUB)
  847.  
  848. POP
  849.  
  850. Normally it's illegal to exit from a GOSUB statement using a standard
  851. GOTO. This can occassionally be inconvenient, especially if an error
  852. occurs, which makes in unacceptable to return to your program from the
  853. precice point you left it.
  854.  
  855.   The POP instruction removes the return address generated by your
  856. GOSUB, and allows you to leave the subroutine in any way you like,
  857. without first having to execute the final RETURN statement. Example:
  858.  
  859.         Do
  860.           Gosub TEST
  861.         Loop
  862.         BYE:
  863.         Print "Popped Out"
  864.         Direct :
  865.         TEST:
  866.         Print "Hi there!"
  867.         If Mouse Key Then Pop : Goto BYE
  868.         Return
  869.  
  870.         IF...THEN...[ELSE] (coose between alternative actions)
  871.  
  872. The IF...THEN instruction allows you to make simple decisions within a
  873. Basic program. The format is:
  874.  
  875. IF conditions THEN statements 1 [ELSE statements 2]
  876.  
  877. "conditions" can be any list of tests including AND and OR. Statements
  878. 1 and Statements 2 must be a list of AMOS Basic instructions. If you
  879. want to jump to a line number or a label, you'll have to include a
  880. separate GOTO command like so:
  881.  
  882.         If test Then Goto Label : This is fine.
  883.                      ----
  884. If you forget about this, and leave the "Goto", you'll get an error
  885. message "procedure not defined".
  886.  
  887.         If test Then Label : Rem THIS CALLS A *PROCEDURE*
  888.  
  889. The scope of this IF...THEN statement is limited to just a single line
  890. of your Basic program. It has now been superceded by the much more
  891. powerful IF...ELSE...ENDIF command.
  892.  
  893.                  IF...[ELSE]...ENDIF (structured test)
  894.  
  895. Although the original form of IF...THEN is undoubtedly useful, it's
  896. rather old fashioned when compared with the facilities found in a
  897. really modern version of Basic such as AMOS. This allows you to execute
  898. whole lists of instructions depending on the outcome of a single test.
  899.  
  900.         IF tests=TRUE
  901.           <List of statements 1>
  902.                "       "
  903.         ELSE
  904.           <List of statements 2>
  905.                "       "
  906.         ENDIF
  907.  
  908. Note: it's illegal to use a normal IF...THEN inside a structured test!
  909. These should be replaced by their equivalent IF...ENDIF instruction ;
  910.  
  911.         If test Then Goto Label Else Label2
  912.  
  913. This now becomes:
  914.  
  915.         If test : Goto Label : Else goto Label2 : Endif
  916.  
  917. or:
  918.  
  919.         If test
  920.           Goto Label
  921.         Endif
  922.  
  923. Here is an example of the IF...ENDIF statement in action:
  924.  
  925.         Input "Enter values for a,b and c";A,B,C
  926.         If A=B
  927.           Print "Equal"
  928.         ELSE
  929.           Print "Different";
  930.           If A<>B and A<>C
  931.             Print ", and C is not the same too!"
  932.           Endif
  933.         End if
  934.  
  935. Each IF statement in your program MUST be paired with a single ENDIF
  936. command as this informs AMOS Basic precisely which group of
  937. instructions are to be executed inside your test.
  938.  
  939. Note that "THEN" is not used by this form of the instruction at all.
  940. This may take a little getting used to if you are already experienced
  941. with one of the other versions of Basic for the Commodore Amiga.
  942.  
  943.                 FOR...NEXT (repeat a section of a code
  944.                       a specific number of times)
  945.  
  946. FOR index=first TO last [STEP inc]
  947. <list of instructions>
  948.          "
  949. NEXT [index]
  950.  
  951. "Index" holds a counter which will be incremented after each and every
  952. loop. At the start of the loop, this counter will be loaded with the
  953. result of the expression "first". The instructions between FOR and the
  954. NEXT are now performed until the NEXT is reached.
  955.  
  956.   "inc" is a value which will be added to the counter after each loop
  957. by the NEXT instruction. If this is omitted, the increment will be
  958. automatically set to 1.
  959.  
  960.   Note that if "inc" is negative, the loop will be halted when the
  961. counter is less than the value in "first". So the entire loop will be
  962. performed in reverse.
  963.  
  964.   Once inside loop, "index" can be read from your program just like a
  965. normal variable. But you are *NOT* allowed to change its value in any
  966. way as this will generate an error message.
  967.  
  968.   Each FOR statement in your program MUST be matched by a single NEXT
  969. instruction. You can't use the shorthand forms found in other Basics
  970. like NEXT R1,R1. Here are a couple of examples of these loops:
  971.  
  972.         For I=32 to 255 : Print Chr$(I);:Next I
  973.  
  974.         For R1=20 to 100 Step 20
  975.           For R2=20 to 100 Step 20
  976.             For A=0 To 3
  977.               Ink A
  978.               Ellipse 160,100,R1,R2
  979.             Next A
  980.           Next R2
  981.         Next R1
  982.  
  983.                    WHILE...WEND (repeat a section of
  984.                     code while a condition is true)
  985.  
  986. WHILE condition
  987.   :     :
  988. list of statements
  989.   :     :
  990. WEND
  991.  
  992. "condition" can be any set of tests you like and can include the
  993. constructions AND, OR and NOT. A check is made on each turn of the
  994. loop. If the test returns a value of -1 (true), then the statements
  995. between the WHILE and WEND will be executed, otherwise the loop will be
  996. aborted and Basic will proceed to the next insturction. Type the
  997. following example:
  998.  
  999.         Input "Type in a number";X
  1000.         Print "Counting to 11"
  1001.         While X<11
  1002.           Inc X
  1003.           Print X
  1004.         Wend
  1005.         Print "Loop terminated"
  1006.  
  1007. The number of times WHILE loop in this program will executed depends on
  1008. the value you input to the routine. If you enter a number larger than
  1009. 10, the loop will never be executed at all. WHILE will therefore only
  1010. execute the statements if the condition is TRUE at the start of your
  1011. program.
  1012.  
  1013.         REPEAT...UNTIL (repeat until a condition is satisfied)
  1014.  
  1015. REPEAT
  1016.  :  :
  1017. list of statements
  1018.  :  :
  1019. UNTIL condition
  1020.  
  1021. REPEAT...UNTIL is similar to WHILE...WEND except that the test
  1022. completion is made at the end of the loop rather than the beginning.
  1023. The loop will be repeated continually until the specified condition is
  1024. FALSE. So it will always be performed at least once in your program.
  1025. Example:
  1026.  
  1027.         Repeat
  1028.           Print "AMOS Basic"
  1029.         Until Mouse Key<>0
  1030.  
  1031.  
  1032.                        DO...LOOP (loop forever)
  1033.  
  1034. DO
  1035. :  :
  1036. list of statements
  1037. :  :
  1038. LOOP
  1039.  
  1040. The DO...LOOP commands take a list of Basic statements and repeat them
  1041. continually. In order to exit from this loop, you'll need to use a
  1042. special EXIT or EXIT IF instruction.
  1043.  
  1044. The advantage of this system is that it's a structure alternative to
  1045. the GOTO loops that tend to crop up in earlier versions of Basic. Take
  1046. the following example:
  1047.  
  1048.         TEST:
  1049.         Input "Another game (Y/N)";AN$
  1050.         If Upper$(AN$)="N" Then Goto BYE
  1051.         GAME : Rem call play game procedure
  1052.         Goto TEST
  1053.         BYE:
  1054.         End
  1055.  
  1056. Now a second version using DO...LOOP
  1057.  
  1058.         Do
  1059.           INput "Another game (Y/N)";AN$
  1060.           Exit If Upper$(AN$)="N"
  1061.           GAME : Rem call play game procedure
  1062.         Loop
  1063.         End
  1064.  
  1065.  
  1066.                      EXIT (Exit from a DO...LOOP)
  1067.  
  1068. EXIT [n]
  1069. The EXIT command exits immediately from one ore more program loops
  1070. created with the FOR...NEXT, REPEAT...UNTIL, WHILE...WEND, or DO...LOOP
  1071. statements. Your AMOS program will now jump directly to the next
  1072. instruction after the current loop.
  1073.  
  1074.   "n" is the numver of loops you wish to leave. If it's omitted, then
  1075. only the innermost loop will be terminated.
  1076.  
  1077.             EXIT IF (Exit from a loop depending on a test)
  1078.  
  1079. EXIT IF expression[,n]
  1080.  
  1081. "expression" consistes of a series of tests in the standard AMOS
  1082. format. The EXIT will only be performed if the result evaluates to -1.
  1083.  
  1084.   The "n" parameter works the same way as using EXIT command.
  1085.  
  1086.            EDIT (stop running the prog and return to Editor)
  1087.  
  1088. EDIT
  1089. The EDIT directive stops the current program and returns to the AMOS
  1090. Basic editor. This can be very useful when you are debugging one of
  1091. your progs.
  1092.  
  1093.                      DIRECT (exit to direct mode)
  1094.  
  1095. DIRECT
  1096. Terminates your program and jumps to the direct mode immediately. You
  1097. can now examine the contents of your variables or list your programs
  1098. out to the printer.
  1099.  
  1100.                       END (Exit from the program)
  1101.  
  1102. END
  1103. This instruction exits from a program. You'll now be given the option
  1104. to return to either the editor or to direct mode.
  1105.  
  1106.                    ON...PROC (jump to one of several
  1107.                   procedures depending on a variable)
  1108.  
  1109. ON v PROC proc1, proc2, proc3, ...procN
  1110.  
  1111. Jumps to a named procedure depending on the contents of variable v.
  1112. Note that any procedures you use in this command CANNOT include
  1113. parameters. If you need to transfer information to this procedure, you
  1114. should place them in *global* variables instead. See PROCEDURES for a
  1115. full explanation of this technique.
  1116.  
  1117.   The ON...PROC command is effectively equivalent to the following:
  1118.  
  1119.         If v=1 Then Proc1
  1120.         If v=2 Then Proc2
  1121.           :    :
  1122.         If v=n Then ProcN
  1123.  
  1124.                ON...GOTO (jump to one of a list of lines
  1125.                        depending on a variable)
  1126.  
  1127. ON v GOTO line1, line2, line3, ...lineN
  1128.  
  1129. The ON GOTO instruction lets your program jump to one of a number of
  1130. lines depending on the result of an expression in v. It's equivalent to
  1131. the following lines:
  1132.  
  1133.         If v=1 Then Goto Line1
  1134.         If v=2 Then Goto Line2
  1135.           :     :
  1136.         If v=n Then Goto LineN
  1137.  
  1138.                   ON...GOSUB (GOSUB one of a list of
  1139.                        routines dependig on var)
  1140.  
  1141. ON var GOSUB line1, line2, line3, ...
  1142.  
  1143. This is identical to ON...GOTO except it uses a gosub rather than a
  1144. goto to jump the line.
  1145.  
  1146.         EVERY n GOSUB (call a subroutine at regural intervals)
  1147.  
  1148. EVERY n GOSUB label
  1149. The ON EVERY statement calls the subroutine at label at regural
  1150. intervals, without interfering with your main program.
  1151.  
  1152.   "n" is the length of your interval in 50ths of a second. The time
  1153. taken for your subroutine to complete must always be less than this
  1154. period, or you'll get an error.
  1155.  
  1156.   After a subroutine has been entered, the system will automatically
  1157. disabled. In order to call this feature continuously, you'll therefore
  1158. need to add EVERY ON command before the final RETURN statement ;
  1159.  
  1160.         Every 50 Gosub TEST
  1161.         Do
  1162.           Print "Main loop"
  1163.         Loop
  1164.         TEST:
  1165.         Inc I : Print "This is call number ";I
  1166.         Every On:Return
  1167.  
  1168.          EVERY n PROC (call a procedure at regural intervals)
  1169.  
  1170. EVERY n PROC name
  1171.  
  1172. EVERY PROC execute the required procedure automatically at regular
  1173. intervals using a powerful interrupt system.
  1174.  
  1175.   "n" is the delay between each successive procedure call measured in
  1176. units of a 50th of a second.
  1177.  
  1178.   As with the previous command, the interrupt must be reactivated
  1179. before leaving your procedure, otherwise the routine will only be
  1180. called just once. So you'll need to use EVERY ON before returning to
  1181. your main program with END PROC ;
  1182.  
  1183.         Every 50 Proc TEST
  1184.         Do
  1185.           Print "Main loop"
  1186.         Loop
  1187.         Procedure TEST
  1188.           Shared I
  1189.           Inc I : Print "This is call number ";I
  1190.           Every On
  1191.         End Proc
  1192.  
  1193.             EVERY ON/OFF (toggle automatic procedure calls)
  1194.  
  1195. EVERY ON/OFF
  1196. EVERY ON restarts the interrupt system used by the EVERY commands. It
  1197. should be called just before the procedure or subroutine has finished
  1198. executing.
  1199.  
  1200. EVERY OFF disables the calls completely. It's automatically executed at
  1201. the start of one of these procedures.
  1202.  
  1203.             BREAK ON/OFF (turn on/off the CTRL+C Break key)
  1204.  
  1205. BREAK ON/OFF
  1206.  
  1207. Normally you can interrupt a program and return to Basic at any time by
  1208. simply pressing CTRL+C. This function can be deactivated using the
  1209. BREAK OFF command. You can restart the Break keys using BREAK ON
  1210.  
  1211. Error handling
  1212.  
  1213.            ON ERROR GOTO (trap an error within a Basic prog)
  1214.  
  1215. ON ERROR GOTO label
  1216.  
  1217. This command allows you to detect and correct the errors inside an AMOS
  1218. Basic program, without having to return to the editor window.
  1219. Sometimes, errors can arise in a program which are impossible to
  1220. predict in advance. Take, for instance, the following routine:
  1221.  
  1222.         Do
  1223.           Input "Enter two numbers";A,B
  1224.           Print A;" divided by ";B;" is ";A/B
  1225.         Loop
  1226.  
  1227. This program works fine until you try to enter a zero for B. You can
  1228. avoid the "division by zero error" by trapping the error with an ON
  1229. ERROR GOTO instruction like so:
  1230.  
  1231.         ON ERROR GOTO label
  1232.  
  1233. Whenever an error occurs in your Basic program, AMOS will now jump
  1234. straight to "label". This will be the starting point of your own error
  1235. correction routine which can fix the error and safely return to your
  1236. main program.
  1237.  
  1238.   Note that error handler MUST exit using a special RESUME instruction.
  1239. You are not allowed to jump back to your program with a normal GOTO
  1240. statement.
  1241.  
  1242.         On Error Goto HELP
  1243.         Do
  1244.           Input "Enter two numbers";A,B
  1245.           Print A;" divided by ";B;" is ";A/B
  1246.         Loop
  1247.         HELP:
  1248.         Print : Print : Bell
  1249.         Print "I'm afraid you've attempted to divide with zero!"
  1250.         Resume Next: Rem Return back to the next instruction.
  1251.  
  1252. In order for this system to work, it's essential that an error does not
  1253. arise inside your error correction routine, otherwise AMOS will halt
  1254. your program ignominiously.
  1255.  
  1256.   The action of ON ERROR GOTO can be disabled by calling ON ERROR with
  1257. no parameters.
  1258.  
  1259.         On Error : Rem Kill error traps
  1260.  
  1261.             ON ERROR PROC (Trap an error using a procedure)
  1262.  
  1263. ON ERROR PROC name
  1264.  
  1265. Selects a procedure which will be called automatically if there's an
  1266. error in the main program. It's really just a structured version of the
  1267. ON ERROR GOTO statement.
  1268.  
  1269.   Although your procedure must be terminated by and END PROC in the
  1270. normal way, you'll need to return to your main program with an
  1271. additional call to RESUME. This can be placed just before the final END
  1272. PROC statement.
  1273.  
  1274.                 RESUME (resume execution of the program
  1275.                             after an error)
  1276.  
  1277. There are five possible formats of this instruction:
  1278.  
  1279.         RESUME
  1280.  
  1281. Jumps back to the statement which caused the error and tries again.
  1282.  
  1283.         RESUME NEXT
  1284.  
  1285. Returns to the instruction just after the one which caused the error.
  1286.  
  1287.         RESUME LINE
  1288.  
  1289. Jumps to as specific line point in your main program. "line" can refer
  1290. to either a label or a normal line number. This may *NOT* be used to
  1291. re-enter a procedure!
  1292.  
  1293.   Procedures are treated slightly differently. If you want to jump to a
  1294. particular label, you have to place a special marker somewhere in the
  1295. procedure you are checking for errors. This may be accomplished using
  1296. the RESUME LABEL command. There are two separate versions.
  1297.  
  1298.         RESUME LABEL label
  1299.  
  1300. Defines the label which is to be returned after an error. This must be
  1301. called outside your error handler just after the original ON ERROR PROC
  1302. or ON ERROR GOTO statement.
  1303.  
  1304.         RESUME LABEL
  1305.  
  1306. Used inside your error handler to jump straight back to the label
  1307. you've set up with the previous command. Example:
  1308.  
  1309.         On Error Proc HELP
  1310.         Resume Label AFTER
  1311.         Error 12
  1312.         Print "Never Printed"
  1313.         AFTER : Print "I've returned here"
  1314.         End
  1315.         Procedure HELP
  1316.           Print "Oh Dear, I think there's an error!"
  1317.           Resume Label
  1318.         Endproc
  1319.  
  1320.                 =ERRN (return the number of last error)
  1321.  
  1322. e=ERRN
  1323.  
  1324. If you're creating your own error handling routines using the ON ERROR
  1325. command, you'll need to be able to check precisely which error has
  1326. occurred in the main program.
  1327.  
  1328.   When an error occurs, ERRN is automatically loaded with its
  1329. identification number. See the Apeendix at the end of this manual for a
  1330. full list of the possible errors.
  1331.  
  1332.         Print ERRN
  1333.  
  1334.           ERROR (generate an error and return to the Editor)
  1335.  
  1336. ERROR n
  1337. The action of the ERROR command is to actually generate an error.
  1338. Supposing you have created a nice little error handling routine which
  1339. is able to cope with all possible disc errors. ERROR provides you with
  1340. a simple way of simulating all the various problems, without the
  1341. inconvenience of the actual error. Example:
  1342.  
  1343.         Error 40
  1344.  
  1345. Quits the program and prints out a "Label not defined" error.
  1346.  
  1347.         Error Errn
  1348.  
  1349. This uses the ERRN function to print the current error condition after
  1350. a problem in your program.
  1351.  
  1352. 8: TEXT AND WINDOWS
  1353.  
  1354. Text Attributes
  1355.                        PEN (set colour of text)
  1356.  
  1357. PEN index
  1358. The PEN instruction sets the colour of all the text which will be
  1359. displayed in the current window. This colour can be chosen from one up
  1360. to 64 different possibilities depending on the gfx mode you're using.
  1361. Example:
  1362.           PEN 6
  1363.  
  1364.           =PEN$(n) (change the pen colour using ctrl chrars)
  1365.  
  1366. a$=PEN$(n)
  1367.  
  1368. PEN$ returns a special control sequence which changes the pen colour
  1369. inside a string. The new pen colour will be automatically assigned
  1370. whenever this string is subsequently printed on the screen. Example:
  1371.  
  1372.         C$=Pen$(2)+"White "+Pen$(6)+"Blue"
  1373.         Print C$
  1374.  
  1375. The string returned by PEN$ is in the format:
  1376.  Chr$(27)+"P"+Chr$(48+n)
  1377.  
  1378.                PAPER (set colour of the text background)
  1379.  
  1380. PAPER index
  1381.  
  1382. "index" can be a number between 0-63.
  1383.  
  1384.                =PAPER$(n) (return a control sequence to
  1385.                          set the paper colour)
  1386.  
  1387. x$=PAPER$(index)
  1388.  
  1389. PAPER$ returns a character string which automatically changes the
  1390. background colour when it's printed on the screen. For example:
  1391.  
  1392.         Pen 1: C$=Paper$(2)+"White "+Paper$(6)+"Blue"
  1393.         Print C$
  1394.  
  1395.  
  1396.                   INVERSE ON/OFF (enter inverse mode)
  1397.  
  1398. INVERSE ON/OFF
  1399.  
  1400. The INVERSE command swaps the text and the background colours.
  1401.  
  1402.                SHADE ON/OFF (shade all subsequent text)
  1403.  
  1404. SHADE ON/OFF
  1405.  
  1406. SHADE ON highlights your text by reducing the brightness of the
  1407. characters with a mask pattern. The shade of your text can be returned
  1408. to normal using SHADE OFF
  1409.  
  1410.                    UNDER ON/OFF (set underline mode)
  1411.  
  1412. UNDER ON/OFF
  1413.  
  1414. UNDER ON underlines your text when it's printed on the screen. UNDER
  1415. OFF turns off the mode.
  1416.  
  1417.                   WRITING (change text writing mode)
  1418.  
  1419. WRITING w1 [,w2]
  1420.  
  1421. The WRITING command allows you to change the writing mode used for all
  1422. subsequent text operations. This determines precisely how your new text
  1423. will be combined with the existing screen data.
  1424.  
  1425.         w1=0   REPLACE (Default)   Your new text will obliterate
  1426.                                    anything underneath it.
  1427.         w1=1   OR                  Merges the characters onto the
  1428.                                    screen with a logical OR.
  1429.         w1=2   XOR                 Chars are combined now with XOR.
  1430.  
  1431.         w1=3   IGNORE              Printing operations are ignored!
  1432.  
  1433. The secont number chooses which parts of the text will be printed on
  1434. the screen. This option can be omitted if required.
  1435.  
  1436.         w2=0   Normal       The text is output to the screen along with
  1437.                             the background.
  1438.         w2=1   Paper        Only the background of the text is drawn on
  1439.                             the screen.
  1440.         w2=2   Pen          Ignores the paper colour and writes the
  1441.                             text on a background of colour zero.
  1442.  
  1443. Do *NOT* confuse this with GR WRITING!
  1444.  
  1445. Cursor functions
  1446. AMOS includes a range of facilities which let you move cursor to any
  1447. part on the screen.
  1448.  
  1449.                      LOCATE (position the cursor)
  1450.  
  1451. LOCATE x,y
  1452. LOCATE x,         Locate moves the text cursor to the coordinates x,y.
  1453. LOCATE ,y         This sets the starting point for all future printing
  1454.                   operations. All screen positions are specified using
  1455. a special set of text coordinates. These are meadured in units of a
  1456. single character relative to the top left corner of the text window.
  1457. For instance the coordinates 15,10 refer to a point 10 chars down and
  1458. 15 to the right.
  1459.  
  1460.   If you attempt to print something outside window limits an error will
  1461. be generated.
  1462.  
  1463.   Note that the current screen is always treated as window 0. So you
  1464. don't have to actually open a window before using one of these
  1465. functions.
  1466.  
  1467.                    CMOVE (relative cursor movement)
  1468.  
  1469. CMOVE w,h
  1470.  
  1471. Moves the cursor a fixed distance away from its present position. If
  1472. your cursor was at 10,10, then typing:
  1473.  
  1474.         CMOVE 5,-5
  1475.  
  1476. would move the cursor to 15,5. Like LOCATE you can omit either one of
  1477. the coordinates as required.
  1478.  
  1479.                  =AT (return a sequence of ctrl chars
  1480.                         to position the cursor)
  1481.  
  1482. x$=AT(x,y)
  1483.  
  1484. The AT function allows you to change the position of text directly from
  1485. inside a character string. It works by returning a string in the
  1486. format:
  1487.           Chr$(27)+"X"+Chr$(27)+"Y"+Chr$(48+Y)
  1488.  
  1489. Whenever this string is printed, the text cursor will be moved to the
  1490. coordinates x,y. For example:
  1491.  
  1492.       A$="This"+At(10,10)+"Is"+At(1,2)+"The Power Of"+At(20,20)+"AMOS!"
  1493.       Print A$
  1494.  
  1495. These AT commands are perfect for hi-score tables as they allow you to
  1496. position our text once and for all during your programs initialisation
  1497. phase. You can now update the score at the correct point on the screen
  1498. using a single print statement. Here's an example:
  1499.  
  1500.         HI_SCORE$=At(20,10)+"Hi Score "
  1501.         SCORE=10000
  1502.         Print HI_SCORE$;SCORE
  1503.  
  1504. Conversion functions
  1505. AMOS Basic provides you with four useful functions which readliy enable
  1506. you to convert between text and graphics coordinates.
  1507.  
  1508.            =XTEXT (convert an x coordinate gfx->text format)
  1509.            =YTEXT (convert an y coordinate gfx->text format)
  1510.  
  1511. t=XTEXT(x)
  1512. t=YTEXT(y)
  1513.  
  1514. These functions take normal x/y coordinates and convert them to text
  1515. coordinates relative to the current window. If the screen coordinate
  1516. lies outside this window then a negative value will be returned. See
  1517. EXAMPLE 8.1.
  1518.  
  1519.          =XGRAPHIC (convert an x coordinate text->gfx format)
  1520.          =YGRAPHIC (convert an y coordinate text->gfx format)
  1521.  
  1522. g=XGRAPHIC(x)
  1523. g=XGRAPHIC(y)
  1524.  
  1525. These functions are effectively the inverse of XTEXT and YTEXT in that
  1526. they take a text X (or) Y coordinate ranging from 0 to the width/height
  1527. of the current window and convert them to absolute screen coordinates.
  1528. See EXAMPLE 8.2
  1529.  
  1530. Cursor commands
  1531. The text cursor serves as a visible starting point of all future text
  1532. operations. It's usually displayed as a flashing horizontal bar,
  1533. although this may be changed using the SET CURS and CURS OFF commands.
  1534.  
  1535.   By moving the cursor on the screen, you can position your text
  1536. practically anywhere you like. Remember, all coordinate measurements
  1537. are taken using TEXT coordinates relative to the current window.
  1538.  
  1539.                           HOME (cursor home)
  1540.  
  1541. HOME
  1542.  
  1543. Moves the text cursor to the top left hand corner of the current window
  1544. (coordinates 0,0)
  1545.  
  1546.                           CDOWN (cursor down)                               93
  1547. CDOWN
  1548.  
  1549. Pushes the text cursor down by a single line.
  1550.  
  1551.  
  1552.  
  1553.                  =CDOWN$ (return a Chr$(31) character)
  1554. x$=CDOWN$
  1555.  
  1556. CDOWN$ is a function which returns a special control character which
  1557. automatically moves the cursor when it is printed. So Print CDOWN$ is
  1558. identical to CDOWN. CDOWN$ allows you to combine several cursor
  1559. movements in a single string. For example:
  1560.  
  1561.         C$="\"+Cdown$
  1562.         For A=0 to 20
  1563.           Print C$;
  1564.         Next A
  1565.  
  1566.  
  1567.                             CUP (cursor up)
  1568. CUP
  1569.  
  1570. Moves the text cursor up a line in the same way that CDOWN moves down.
  1571.  
  1572.                   =CUP$ (return a Chr$(30) character)
  1573. x$=CUP$
  1574.  
  1575. CUP$ returns a control string which moves the cursor up by a single
  1576. character.
  1577.  
  1578.                           CLEFT (cursor left)
  1579. CLEFT
  1580.  
  1581. Displaces the text cursor one character to the left.
  1582.  
  1583.               =CLEFT$ (Control string for CLEFT Chr$(29))
  1584. x$=CLEFT$
  1585.  
  1586. Moves the text cursor one character left. Works like =CUP$.
  1587.  
  1588.                          CRIGHT (cursor right)
  1589. CRIGHT
  1590.  
  1591. Moves cursor one place to the right.
  1592.  
  1593.        =CRIGHT$ (Generate a Chr$(28) control string for CRIGHT)
  1594.  
  1595. x$=CRIGHT$
  1596.  
  1597. Is the opposite of CLEFT$.
  1598.  
  1599.           XCURS (return the X coordinate of the text cursor)
  1600.           YCURS (return the Y coordinate of the text cursor)
  1601.  
  1602. x=XCURS
  1603. y=YCURS
  1604.  
  1605. XCURS is a variable containing the current X coordinate of the text
  1606. cursos (in text format). YCURS holds the Y coordinate of the cursor.
  1607.  
  1608.                    SET CURS (set text cursor shape)
  1609.  
  1610. SET CURS L1,L2,L3,L4,L5,L6,L7,L8
  1611.  
  1612. This instructoin allows you to change the shape of the cursor to
  1613. anything you like. The shape is specified by a list of bit-patterns
  1614. held in the parameters L1-L8, Each parameter determines the appearance
  1615. of the horizontal line of the cursor, numbered from top to bottom.
  1616.  
  1617.   Every bit represnts a single point in the current cursor line. If
  1618. it's set to 1 then the point will be drawn using colour number 3 -
  1619. otherwise it will be displayed in the current PAPER colours. Example:
  1620.  
  1621.         L1=%11111111
  1622.         L2=%11111110
  1623.         L3=%11111100
  1624.         L4=%11111000
  1625.         L5=%11110000
  1626.         L6=%11100000
  1627.         L7=%11000000
  1628.         L8=%10000000
  1629.         Set Curs L1,L2,L3,L4,L5,L6,L7,L8
  1630.  
  1631.                CURS ON/OFF (enable/disable text cursor)
  1632.  
  1633. CURS ON                          makes text cursor visible
  1634. CURS OFF                         hides the cursor in current window
  1635.  
  1636.                      MEMORIZE X/Y (save the X or Y
  1637.                     coordinates of the text cursor)
  1638. MEMORIZE X
  1639. MEMORIZE Y
  1640.                The Memorize commands store the current cursor position.
  1641.  
  1642.                    REMEMBER X/Y (restore the X or Y
  1643.                     coordinate of the text cursor)
  1644. REMEMBER X
  1645. REMEMBER Y
  1646.                REMEMBER positions the cursor at the coordinates saved
  1647.                by a previous call to MEMORIZE. If MEMORIZE has not been
  1648.           used then the coordinates will be set to zero. See EXAMPLE 8.3
  1649.  
  1650.          CLINE (clear part or all of the current cursor line)
  1651.  
  1652. CLINE [n]
  1653.  
  1654. Clears the line on which the cursor is positioned. If n is present then
  1655. "n" characters are cleared starting at the current cursor position.
  1656.  
  1657.           CURS PEN (choose a new colour for the text cursor)
  1658.  
  1659. CURS PEN n
  1660.  
  1661. Changes the colour of the text cursor to index number n.
  1662.  
  1663. Text Input/Output
  1664.  
  1665.           CENTRE (print a line of text centred on the screen)
  1666.  
  1667. CENTRE a$
  1668.  
  1669. Takes a string of characters in a$ and prints it in the centre of the
  1670. screen. This text is always output on the current cursor line.
  1671.  
  1672.         Locate 0,1
  1673.         Centre "This is a centered TITLE"
  1674.  
  1675.                        =TAB$ (print tabulation)
  1676.  
  1677. x$=TAB$
  1678.  
  1679. TAB$ returns a control character known as a TAB (Ascii 9). When this
  1680. character is printed the text cursor will be immediately moved several
  1681. places to the right. The size of this movement can be set using the SET
  1682. TAB kommand. As a default, the tab spacing is set to four (4).
  1683.  
  1684.                     SET TAB (change the tabulation)
  1685.  
  1686. SET TAB n
  1687.  
  1688. This specifies the distance the text cursor will move when TAB
  1689. character is printed.
  1690.  
  1691.                         REPEAT$ (repeat string)
  1692.  
  1693. x$=REPEAT$(a$,n)
  1694.  
  1695. The REPEAT$ function allows you to print out the same string of
  1696. characters several times using a single PRINT statement.
  1697.  
  1698.   It works by adding a sequenve of control characters into variable X$.
  1699. When this string is printed, AMOS simply repeats a$ to the screen n
  1700. times. Possible values for n range between 1 and 207. See EXAMPLE 8.4.
  1701.  
  1702. The format of the control string is:
  1703.  
  1704.         Chr$(27)+"RO"+A$+Chr$(27)+"R"+Chr$(48+n)
  1705.  
  1706. Advanced Text Commands
  1707.  
  1708.              ZONE$ (set up a zone around a piece of text)
  1709.  
  1710. x$=ZONE$(a$,n)
  1711.  
  1712. The ZONE$ function surrounds a section of text with a screen zone.
  1713. After you have defined one of these zones you can check for coillisions
  1714. between the zone and the mouse using the ZONE function. This allows you
  1715. to create powerful on-screen menus and dialogue boxes without having to
  1716. resort to any complicated programming tricks.
  1717.  
  1718.   a$ is a string containing the text for one the "Buttons" in your
  1719. dialogue box. This button will be activated automatically when you
  1720. print x$ to the screen.
  1721.  
  1722.   n specifies the number of screen zone to be defined. The max. number
  1723. of these zones depends on the value you specified with RESERVE ZONE.
  1724.  
  1725.   See the EXAMPLE 8.5 program in the MANUAL folder. The format of the
  1726. control string is:
  1727.                    Chr$(27)+"ZO"+A$+Chr$(27)+"R"+Chr$(48+n)
  1728.  
  1729.                   BORDER$ (add a border to some text)
  1730.  
  1731. x$=BORDER$(a$,n)
  1732.  
  1733. This returns a string of control characters which instructs AMOS to
  1734. draw a border aound the required text. It's commonly used in
  1735. conjunction with the ZONE$ command to produve the fancy buttons found
  1736. in dialogue boxes and alert windows.
  1737.  
  1738.   n is the border number ranging from 1 to 16 and a$ holds the text to
  1739. be enclosed by the border. The text in a$ will start at the current
  1740. cursor position so don't be surprised when you get strange results
  1741. printing at 0,0. To create a screen zone by a border try this:
  1742.  
  1743.         Print Border$(Zone$(" CLICK HERE ",1),2)
  1744.  
  1745. This would enclose the text with zone number 1 and border 2. The
  1746. control sequence is:
  1747.                      Chr$(27)+"EO"+A$+Chr$(27)+"R"+Chr$(48+n)
  1748.  
  1749.                   HSCROLL (horizontal text scrolling)
  1750.  
  1751. HSCROLL n
  1752.  
  1753. This scrolls all the text in the currently open window horizontally by
  1754. a single character position. n can take the following values:
  1755.  
  1756.         1 = Move current line to the left
  1757.         2 = Scrolls entire screen to the left
  1758.         3 = Move current line to the right
  1759.         4 = Move screen to the right
  1760.  
  1761.                        VSCROLL (vertival scroll)
  1762.  
  1763. VSCROLL n
  1764.  
  1765. Scrolls the text in the currently open window vertically.
  1766.  
  1767.         1 = Any text at the cursor line and below is scrolled down
  1768.         2 = Text at cursor line or below is moved up
  1769.         3 = Only text from the top of the screen to the cursor line
  1770.              is scrolled up
  1771.         4 = Text from top of the screen to the current cursor position
  1772.              is scrolled down
  1773.                                               Blank lines are inserted
  1774.                      to pad out the gap left by the scrollingoperation.
  1775.  
  1776. Windows
  1777. The AMOS windowing commands allow you to restrict your text and
  1778. graphics operations just a part of the current screen.
  1779.  
  1780.   AMOS windows can be used with the zone commands to produce effective
  1781. dialogue boxes such as file selectors and high score tables. A typical
  1782. warning box, for instance, can be easily generated with just a couple
  1783. lines of AMOS Basic.
  1784.  
  1785.                       WINDOPEN (create a window)
  1786.  
  1787. WINDOPEN n, x, y, w, h [,border [,set]]
  1788.  
  1789. The WINDOPEN instruction opens a window and displays it on the screen.
  1790. This window will now be used for all subsequent text operations.
  1791.  
  1792.   n is the number of the window to be defined. AMOS allows you to
  1793. create as many windows as you like, limited only by the amount of
  1794. available memory. As a default, window number zero is assigned to the
  1795. current screen. So don't attempt to re-open this window using WINDOPEN
  1796. or change it with WIND SIZE or WIND MOVE.
  1797.  
  1798.   x,y are the graphics coordinates of the top left hand corner of your
  1799. new window. Since AMOS windows are drawn using the Amiga's blitter
  1800. chip, the window area must always lie on a 16-pixel boundary. In order
  1801. to achieve this, the x coordinates are automatically rounded to the
  1802. nearest multiple of 16. Additionally, if you've included a border for
  1803. your window, the X coordinate will be incremented by a further eight.
  1804. This will ensure that the working area of your window always starts at
  1805. the correct screen boundary. There are no restrictions whatsoever on
  1806. the y coordinates.
  1807.  
  1808.   w,h specify the size in characters of the new window. These
  1809. dimensios must always be divisible by 2.
  1810.  
  1811.   "border" selects a border style for your window. There are 16
  1812. possible styles, with values ranging between 1 and 16.
  1813.  
  1814.   Window borders can also include up to two optional title lines. One
  1815. title is displayed along the top of the window and another may be added
  1816. at the bottom.
  1817.  
  1818.   AMOS windows may contain either text or graphics, just like the
  1819. intuition system. Each window can be assigned it's own individual
  1820. character set with the powerful WINDOW FONT command. There's also a
  1821. powerful WIND SAVE instuction which saves the screen area inside your
  1822. windows. Whenever you move one of these windows the contents underneath
  1823. will be automatically redrawn. For example:
  1824.  
  1825.         For W=1 To 3
  1826.           Windopen W,(W-1)*96,50,10,101
  1827.           Paper W+3 : Pen W+6 : Clw
  1828.           Print "Window ";W
  1829.         Next W
  1830.  
  1831. You can flick between these windows using the WINDOW command. Try
  1832. typing the following statements from the Direct mode:
  1833.  
  1834.         Window 1 : Print "AMOS"
  1835.         Window 3 : Print "in action!"
  1836.         Window 2 : Print "Basic"
  1837.  
  1838. The active window can always be distinguished by a flashing cursor -
  1839. through this can be turned off using the CURS OFF command if required.
  1840.  
  1841.                    WINDOW FONT (change window font)
  1842.  
  1843. WINDOW FONT n
  1844.  
  1845. Changes the font used by the current window to set n. n is the number
  1846. of a graphics font which has been previously installed with the GET
  1847. FONT command. This font *must* have dimensions of exactly 8x8.
  1848. Proportional fonts are not allowed.
  1849.  
  1850.   Since the window vborders make use of some of these characters, you
  1851. may get rather odd results when you're using standard WBench fonts.
  1852.  
  1853.           WIND SAVE (save the contents of the current window)
  1854.  
  1855. WIND SAVE
  1856.  
  1857. The WIND SAVE command allows you to move your windows anywhere on the
  1858. screen without corrputing your existing display.
  1859.  
  1860.   Once you've activated this feature, any windows you subsequently open
  1861. will automatically save the entire contents of the windows underneath.
  1862. This area will be redrawn whenever you close a window or move it to a
  1863. new position.
  1864.  
  1865.   It's important to note that this option saves the contents of the
  1866. current window, rather than the one you are defining with WIND OPEN.
  1867.  
  1868.   At the start of your program the current window will be the default
  1869. screen and will take up a massive 32k of memory. If you wished to save
  1870. the background underneath a dialogue box the most of this memory would
  1871. be completely wasted.
  1872.  
  1873.   The solution is to create a dummy window of the required size, and to
  1874. position it over the zone you wish to save. You can now execute a WIND
  1875. SAVE command and continue with your program as normal.
  1876.  
  1877.   When you subsequently call up your dialogue box the area underneath
  1878. will be saved as part of your dummy window. So it will be automatically
  1879. restored after your box has been removed.
  1880.  
  1881.                BORDER (change the window border of the)
  1882.                             current screen)
  1883.  
  1884. BORDER n,paper,pen
  1885.  
  1886. The BORDER command sets the border of the current window to style
  1887. number n. This border is drawn using a group of characters installed in
  1888. the default font. It is therefore possible to create your own border
  1889. styles using the font definer accessory.
  1890.  
  1891.   The paper and pen options allow you to freely choose the colours of
  1892. your border. Acceptable border numbers range from 1 to 16.
  1893.  
  1894.   Any of the parameters may be omitted from this instuction so the
  1895. following commands are legal:
  1896.  
  1897.         BORDER 2,,
  1898.         BORDER 2,,3
  1899.  
  1900.                  TITLE TOP (define the upper title for
  1901.                           the current window)
  1902.  
  1903. TITLE TOP t$
  1904.  
  1905. This instruction sets the top line of the current window to the title
  1906. string in t$. Only bordered windows may be titled in this way.
  1907.  
  1908.         Windopen 5,1,1,20,10
  1909.         Title Top "Window Number 5"
  1910.         Wait Key
  1911.  
  1912.  
  1913.  
  1914.                TITLE BOTTOM (define the lower title for
  1915.                           the current window)
  1916.  
  1917. TITLE BOTTOM b$
  1918.  
  1919. This command assigns the string b$ to the bottom title of the current
  1920. window.
  1921.  
  1922.                       WINDOW (change current window)
  1923.  
  1924. WINDOW n
  1925.  
  1926. WINDOW activates the window n as the current window. If the automatic
  1927. saving system has been initiated, this window be immediately redrawn
  1928. along with any of its contents. See EXAMPLE 8.6 in the Manual folder.
  1929.  
  1930.                =WINDON (Return the value current window)
  1931.  
  1932. w=WINDOW
  1933.  
  1934. WINDON returns the identification number of the currently active
  1935. window.
  1936.  
  1937.                  WIND CLOSE (close the current window)
  1938.  
  1939. WIND CLOSE
  1940.  
  1941. Deletes the current window. Use the WIND SAVE command if you want the
  1942. area that was hidden be redrawn by.
  1943.  
  1944.                        WIND MOVE (move a window)
  1945.  
  1946. WINDMOVE x,y
  1947.  
  1948. Windmove moves the current window to graphics coordinates x,y. As with
  1949. the original window definitions the x coordinate will be rounded to the
  1950. nearest 16-pixel boundary.
  1951.  
  1952.            WIND SIZE (change the size of the current window)
  1953.  
  1954. WIND SIZE sx,sy
  1955.  
  1956. This command changes the size of an AMOS window. The new sizes, sx and
  1957. sy, are specified in units of a single character. Sx must be divisible
  1958. by two. See EXAMPLE 8.7.
  1959.  
  1960.   If you've previously called the WIND SAVE command, the original
  1961. contents of your window will be redrawn by this instruction. If the new
  1962. window is smaller than the original one, any parts of the image which
  1963. lie outside will be lost. Alternatively, if you've expanded your
  1964. window, the area around your saved region will be filled with the
  1965. current paper colour. Also note that after a WIND SIZE command the text
  1966. cursor is always reset to coordinates 0,0.
  1967.  
  1968.                     CLW (clear the current window)
  1969.  
  1970. CLW
  1971.  
  1972. Erases the contents of the current window and fills it with the current
  1973. PAPER colour.
  1974.  
  1975. Slider bars
  1976. AMOS incorporates three insturctions which allow you to display a
  1977. standard slider bar on the screen. These sliders cannot be manipulated
  1978. directly with the mouse. In order to create a working slider bar,
  1979. you'll need to write a small Basic routine to perform this operate in
  1980. your main program. Due to the sheer power of the AMOS system, this is
  1981. extremely easy to accomplish, and the results can be extremely
  1982. impressive, as can be seen from EXAMPLE 8.8.
  1983.  
  1984.                   HSLIDER (draw a horizontal slider)
  1985.  
  1986. HSLIDER x1,y1 OT x2,y2,total,pos,size
  1987.  
  1988. Draws a horizontal slider bar from x1,y1 to x2,y2. "total" is the
  1989. number of individual units which the slider will be divided into. Each
  1990. unit represents a single item in the object you are controlling with
  1991. the slider. TSo in the editor window, "total" would be set to the
  1992. number of lines in the current program. The size of each unit is
  1993. calculated from the following formula:
  1994.  
  1995.         (X2-X1)/Total
  1996.  
  1997. "pos" is the position of the slider box from the start of the slider,
  1998. measured in the units you specified using "total". "size" is the length
  1999. of the slider box in the previous units. See EXAMPLE 8.9.
  2000.  
  2001.                    VSLIDER (draw a vertical slider)
  2002.  
  2003. VSLIDER x1,y1 TO x2,y2,total,pos,size
  2004.  
  2005. VSLIDER is almost identical to the previous HSLIDER insturction. It
  2006. displays a simple slider from x1,y1 to x2,y2. See EXAMPLE 8.10.
  2007.  
  2008.                   SET SLIDER (sets the fill patterns
  2009.                            used in a slider)
  2010.  
  2011. SET SLIDER b1,b2,b3,pb,s1,s2,s3,ps
  2012.  
  2013. Although this command looks incredibly complicated, it's actually
  2014. rather simple. SET SLIDER enters the colours and patterns to be used in
  2015. the slider bars created with the H/VSLIDER commands.
  2016.  
  2017.   "b1,b2,b3" set the ink, paper and outline colours for the background
  2018. of the box. "pb" chooses the fill pattern to be used for these regions.
  2019.  
  2020.   "s1,s2,s3" input the colours of the slider box, and "sp" selects the
  2021. pattern it is to be filled with.
  2022.  
  2023.   "bp" and "sp" can be any fill patterns you wish. As usual, negative
  2024. value refer to a sprite image from the current sprite bank. This allows
  2025. you to create amazing colorful slider boxes.
  2026.  
  2027. Fonts
  2028. There are two different types of fonts available in AMOS - text fonts
  2029. and graphic fonts. The text fonts are those used by the PRINT and
  2030. WINDOW commands. Text fonts are known as character sets and each AMOS
  2031. Basic window can have its own individual set. The graphic fonts are
  2032. much more flexible and offer a wider range of styles:
  2033.  
  2034. Graphic text
  2035. Your Amiga computer is capable of displaying an impressive variety of
  2036. different text styles. The original WorkBench disc was supplied with
  2037. eight attractive fonts in a range of sizes, and many more of these
  2038. fonts are freely available from the public domain. If you've upgraded
  2039. to WorkBench 1.3, you'll also be able to design your own fonts using
  2040. the FED program on the Extras disc.
  2041.  
  2042.   AMOS provides you with total support for these fonts. Text can be
  2043. printed in any of the available typefaces at any point on the screen.
  2044.  
  2045.   AMOS fonts can be used to add spice to even the most Basic games.
  2046. These are invaluable for producing the loading screens and hi-score
  2047. tables in your games. So it's a good idea to make full use of them in
  2048. your progs.
  2049.  
  2050.                       TEXT (print graphical text)
  2051.  
  2052. TEXT x,y,t$
  2053.  
  2054. TEXT prints a line of text in t$ at graphical coordinates x,y. All
  2055. coordinates are measured relative to the characters baseline. This can
  2056. be determined using a special TEXT BASE function.
  2057.  
  2058.   Normally the baseline is positioned at the bottom of the character,
  2059. but some lowercase letters, such as "g", have a "tail" which extends
  2060. slightly below this point.
  2061.  
  2062.   As a default the type styles is set to eight-point Topaz. This may be
  2063. changed at any time using the SET FONT instruction. Try the following
  2064. program and notice how text can be placed at any pixel position on the
  2065. screen.
  2066.  
  2067.   Do
  2068.     Ink Rnd(15)+1,Rnd(15): Text Rnd(320)+1,Rnd(198)+1,"AMOS Basic"
  2069.   Loop
  2070.  
  2071. Al so notice how the colour of your text is set with INK rather than
  2072. the expected PEN and PAPER commands. This emphasizes the fact that the
  2073. TEXT command is basically a graphical instruction. So the control
  2074. sequences created by functions like CUP$ will be printed on the screen
  2075. instead of being correctly interpreted.
  2076.  
  2077.   There is no automatic line feed when the text reaches the end of the
  2078. current window. If you attempt to print something too large, the text
  2079. will be neatly clipped at the existing screen boundary. This can be
  2080. seen by the example below:
  2081.  
  2082.         Print String$("A",100):Text 0,100,String$("A",100)
  2083.  
  2084.            GET FONTS (create a list of all available fonts)
  2085.  
  2086. GET FONTS
  2087.  
  2088. The GET FONTS command creates an internal list of the all fonts
  2089. available from the current start-up disc. This list is essential to the
  2090. running of the SET FONT command, so you should always call GET FONTS at
  2091. least once before attempting to change the present font setting. The
  2092. contents of this list can be examined using the FONT$ function.
  2093.  
  2094.   WARNING! In order for GET FONTS to work, your current AMOS work disc
  2095. must always contain a copy of the standard LIBS folder along with its
  2096. contents. It's important to remember this fact when you are
  2097. distributing run-only or compiled programs because unless your discs
  2098. contain the required files, AMOS Basic will almost certainly crash!
  2099.  
  2100.            GET DISC FONTS (create a list of the disc fonts)
  2101.  
  2102. GET DISC FONTS
  2103.  
  2104. This command is identical to the previous GET FONTS instruction except
  2105. that it only searches for fonts on the disc. These fonts are contained
  2106. in the FONTS folder on your current boot-disc. If you want to use your
  2107. own fonts with AMOS basic, you'll need to copy these onto your normal
  2108. start-up disc. See the manual supplied with your Amiga for details of
  2109. this procedure.
  2110.  
  2111.             GET ROM FONTS (create a list of the rom fonts)
  2112.  
  2113. GET ROM FONTS produces a list of the fonts which are built into Amiga's
  2114. rom chips. At the present time there are just two of these fonts:
  2115. Eight-point Topaz and nine-point Topaz.
  2116.  
  2117.            =FONT$ (return details about the available fonts)
  2118.  
  2119. a$=FONT$(n)
  2120.  
  2121. Returns a string of 38 chars which describes font number n. This
  2122. function allows you to examine the font list created by a previous call
  2123. to one of the GET FONT commands.
  2124.  
  2125.   a$ contains a list of characters which hold the name and type of your
  2126. font. If a font does not exist, a$ will be loaded a null value "",
  2127. otherwise a string will be returned in the following format:
  2128.  
  2129.         Character     Description
  2130.            1-29       Font name
  2131.           30-33       Font height
  2132.           34-37       Identifier (set to either Disc or Rom)
  2133.  
  2134. See EXAMPLE 8.11!
  2135.  
  2136.                   SET FONT (choose a font for use by
  2137.                          the TEXT instruction)
  2138.  
  2139. SET FONT n
  2140.  
  2141. SET FONT changes the character set used by the TEXT command to font
  2142. number n. If the font is stored on the disc it will be automatically
  2143. loaded into your Amiga's memory. At the same time any previously sets
  2144. which are not in use will be removed. See EXAMPLE 8.12.
  2145.  
  2146.                        SET TEXT (set text style)
  2147.  
  2148. SET TEXT style
  2149.  
  2150. Allows you to change the style of a font. There are three styles to
  2151. choose from. "style" is a bit pattern in the following format:
  2152.  
  2153.         Bit  Effect
  2154.          0   Underline        By setting the appropriate bits in this
  2155.          1   Bold             pattern you can choose between a total
  2156.          2   Italic           of eight different text styles.
  2157.  
  2158.               =TEXT STYLE (return the current text style)
  2159.  
  2160. s=TEXT STYLE
  2161.  
  2162. This function returns the text style set from the SET TEXT command. The
  2163. result in "s" is a bit-map in the same format as that used by SET TEXT.
  2164.  
  2165.              =TEXT LENGTH (return the length of a section                           of graphic text)
  2166.  
  2167. w=TEXT LENGTH(t$)
  2168.  
  2169. The TEXT LENGTH function returns the width in pixels of the character
  2170. string a$ in the current font. The width of a character varies
  2171. depending on the size of your fonts. In addition, proportional fonts
  2172. such as Helvetica assign different widths for each individual
  2173. character.
  2174.  
  2175.                =TEXT BASE (return the current text base)
  2176.  
  2177. b=TEXT BASE
  2178.  
  2179. This function returns the position of the baseline of your font. The
  2180. baseline is the number of pixels between the top of a character and
  2181. point it will be printed on the screen. It's basically similar to the
  2182. hot spot of a sprite or bob.
  2183.  
  2184. Installing new fonts
  2185. If you wish to use your own fonts within AMOS Basic, you'll need to
  2186. install them onto a copy of your AMOS program disc. The basic procedure
  2187. is as follows:
  2188.  
  2189.  - Copy the required font files into the FONTS: directory of your boot-
  2190.    disc.
  2191.  - Further information can be found in the Extra's manual supplied with
  2192.    the Workbench 1.3 upgrade.
  2193.  
  2194. Troubleshooting
  2195. Problem:  GET FONTS seems to ignore any of the fonts on the current
  2196.           disc.
  2197. Solution: You've propably removed the original boot disc from your
  2198.           default drive. The Amiga's library routines expect to find
  2199.           the FONTS: directory on your start-up disc. This can be
  2200.           changed using the ASSIGN program in the UTILITIES folder.
  2201.  
  2202. Problem:  GET FONTS crahes the Amiga completely.
  2203. Solution: This problem can easily occur when you're creating programs
  2204.           in run-only or compiled format. GET FONTS requires the
  2205.           discfont.library in the LIBS folder in order to work.
  2206.  
  2207. Problem:  The SET FONT command returns a "fonts not examined" error.
  2208. Solution: Add a cal to GET FONTS to the start of your program.
  2209.  
  2210. 9:MATHS FUNCTIONS
  2211.  
  2212. AMOS Basic includes a wide variety of the more commonly needed
  2213. mathematical functions. To conserve memory, AMOS uses the standard
  2214. Amiga library routines. The appropriate libraries will be loaded
  2215. automatically from your workbench disc the first time you call one of
  2216. these functions in a particular session. You should therefore ensure
  2217. that the current disc contains the file MATHTRANS.LIBRARY in the LIBS
  2218. folder.
  2219.  
  2220. Trigonometric functions
  2221. The trigonometric functions provide you with a useful array of
  2222. mathematical tools. These can be used for a variety of purposes, from
  2223. education to the creation of complex musical wabeforms.
  2224.  
  2225.                          DEGREE (use degrees)
  2226.  
  2227. DEGREE
  2228.  
  2229. Generally all angles are specified in radians. Since radians are rather
  2230. difficult to work with, it's possible to instruct AMOS to accept angles
  2231. in degrees. Once you've activated this feature any subsequent calls to
  2232. the trig functions will expect you to use degrees.
  2233.  
  2234.                       RADIAN (use radian measure)
  2235.  
  2236. RADIAN
  2237.  
  2238. THe RADIAN directive informs AMOS that all future angles are to be
  2239. entered using radians - this is the default.
  2240.  
  2241.                          =PI# (a constant PI)
  2242.  
  2243. a#=PI#
  2244.  
  2245. This function returns the number called PI which represents the result
  2246. of the division of the diameter of a circle by the circumference. PI is
  2247. used by most of the trigonometric functions to calculate angels. Note
  2248. that a # character is part of the token name! This is to avoid clashes
  2249. with your own variable names.
  2250.  
  2251.                               =SIN (sine)
  2252.  
  2253. s#=SIN(a)
  2254. s#=SIN(a#)
  2255.  
  2256. The SIN functions calculates the sine of the angle in n. Note that the
  2257. function always returns a floating point number.
  2258.  
  2259.                              =COS (cosine)
  2260. c#=COS(a[#])
  2261.  
  2262. The cosine function computes the cosine of an angle.
  2263.  
  2264.                             =TAN (tangent)
  2265.  
  2266. t#=TAN(a[#])
  2267.  
  2268. TAN generates the tangent of an angle.
  2269.  
  2270.                             =ACOS (arc cos)
  2271.  
  2272. c#=ACOS(n#)
  2273.  
  2274. The ACOS function takes a number between -1 and +1 and calculates the
  2275. angle which would be needed to generate this value with COS.
  2276.  
  2277. Note, we haven't provided you with ASIN, because it's not really
  2278. needed. It can be readily computed using the formula:
  2279.  
  2280. ASIN(X)=90-ACOS(X) : Rem Measured in degrees.
  2281. ASIN(X)=1.5708-ACOS(X) : Rem using radians
  2282.  
  2283.                           =ATAN (arc tangent)
  2284.  
  2285. t#=ATAN(n#)
  2286.  
  2287. ATAN returns the arctan of a number.
  2288.  
  2289.                         =HSIN (hyperbolic sine)
  2290.  
  2291. s#=HSIN(a[#])
  2292.  
  2293. HSIN computes the hyperbolic sine of angle a.
  2294.  
  2295.                        =HCOS (hyperbolic cosine)
  2296.  
  2297. c#=HCOS(a[#])
  2298.  
  2299. HCOS calculates the hyperbolic cosine of angle a.
  2300.  
  2301.                       =HTAN (hyperbolic tangent)
  2302.  
  2303. t#=HTAN(a[#])
  2304.  
  2305. HTAN returns the hyperbolic tangent of the angle a.
  2306.  
  2307. Standard mathematical functions
  2308.  
  2309.                            =LOG (logarithm)
  2310.  
  2311. r#=LOG(v[#])
  2312.  
  2313. LOG returns the logarithm in base 10 (log 10) of the expression in v#.
  2314.  
  2315.                       =EXP (exponential function)
  2316.  
  2317. r#=EXP(e#)
  2318.  
  2319. Calculates the exponential of e#. Example:
  2320.  
  2321.         Print Exp(1)
  2322. ( result : 2.71828 )
  2323.  
  2324.                         =LN (natural logarithm)
  2325.  
  2326. r#=LN(l#)
  2327.  
  2328. LN computes the natural of naperian logarithm of l#.
  2329.  
  2330.                           =SQR (square root)
  2331.  
  2332. s#=SQR(v[#])
  2333.  
  2334. SQR calculates the square root of a number.
  2335.  
  2336.  
  2337.  
  2338. r=ABS(v[#])
  2339.  
  2340. ABS returns the absolute value of v, taking no account of its sign.
  2341.  
  2342.           =INT (convert floating point number to an integer)
  2343.  
  2344. i=INT(v#)
  2345.  
  2346. INT rounds a floating point number in v down to the nearest whole
  2347. integer.
  2348.  
  2349.                    =SGN (find the sign of a number)
  2350.  
  2351. s=SGN(v[#])
  2352.  
  2353. SGN returns a value of representing the sign of a number. There are
  2354. three possibilities.
  2355.  
  2356.         -1, if v is negative
  2357.          0, if v is zero
  2358.          1, if v is positive
  2359.  
  2360. Creating random sequences
  2361.  
  2362.                     =RND (random number generation)
  2363.  
  2364. RND generates a random integer between 0 and n inclusive. But if n is
  2365. less than zero, RND will return the last value it produced. This can be
  2366. very useful when debugging one of your programs.
  2367.  
  2368.               RANDOMIZE (set the seed of a random number)
  2369.  
  2370. RANDOMIZE seed
  2371.  
  2372. In practice, the numbers produced by the RND function are not really
  2373. random. They're computed internally using a complex mathematical
  2374. formula. The starting point for this calculation is taken from a number
  2375. known as the "seed". This seed is set to a standard value whenever you
  2376. load AMOS Basic into the computer. So the sequence of numbers generated
  2377. by RND will be exactly the same every time you run your game!
  2378.  
  2379.   The RANDOMIZE command allows you to set the seed value directly, so
  2380. that the numbers would really look like random every time.
  2381.  
  2382.   "seed" can be any value you wish. In order to generate a true random
  2383. numbers, you need some way of varying the seed from game to game. This
  2384. can be achieved using the TIMER instruction:
  2385.  
  2386.         Randomize Timer
  2387.  
  2388. TIMER is a Basic function which returns the amount of time which has
  2389. elapsed since your Amiga was switched on in the current session. All
  2390. timings are measured in units of a 50th of a second.
  2391.  
  2392. Manipulating numbers
  2393.  
  2394.                  =MAX (get the maximum of two values)
  2395.  
  2396. r=MAX(x,y)
  2397. r#=MAX(x#,y#)
  2398. r$=MAX(x$,y$)    MAX compares two expressions and returns the largest.
  2399.                  These expressions can be composed of numbers or
  2400. strings of characters, providing you don't try to mix different types
  2401. of expressions in one instruction.
  2402.  
  2403.         Print Max(10,4)
  2404. ( result : 10 )
  2405.  
  2406.                 =MIN (return the minimum of two values)
  2407.  
  2408. r=MIN(x,y)
  2409. r#=MIN(x#,y#)
  2410. r$=MIN(x$,y$)    This works the same way the =MAX does, except returns
  2411.                  the minimum value of compared numbers/strings.
  2412.  
  2413.                SWAP (swap the contents of two variables)
  2414.  
  2415. SWAP x,y
  2416. SWAP x#,y#
  2417. SWAP x$,y$       Swaps the data between any two variables of the same
  2418.                  type.
  2419.  
  2420.              FIX (set precision of floating point output)
  2421.  
  2422. FIX(n)
  2423.  
  2424. Changes the way your floating point numbers will be displayed on the
  2425. screen or printer. There are four possibilities.
  2426.  
  2427. If 0<n<16 then n denotes the number of figures to be output after
  2428.           the decimal point.
  2429. If n> 16  the printout will be proportional and any trailing zeros will
  2430.           be removed.
  2431. If n<0    Then all floating point numbers will be displayed in
  2432.           exponential format, and the absolute value of n will
  2433.           determine the number of digits after the decimal point.
  2434.  
  2435. If n=16   then the format will be returned to normal
  2436.  
  2437.         Fix(-4) : Print PI#
  2438.  
  2439.                 DEF FN (create a user-defined function)
  2440.  
  2441. DEF FN name [(list)]=expression
  2442.  
  2443. The DEF FN command lets you create your own user-defined functions
  2444. within an AMOS Basic program. These can be used to compute commonly
  2445. needed values quickly and easily.
  2446.  
  2447.   "nane" is the name of the function you wish to define. "list" is a
  2448. set of variables separated by commas. Only the type of these variables
  2449. is significant. When you call your function, any variables you enter
  2450. with, will be automatically subsituted in the appropriate positions.
  2451.  
  2452.   "expression" can include any of the standard AMOS functions you wish.
  2453. Like all Basic expressions, it's limited just to a single line of prog.
  2454.  
  2455.                   FN (call a user-defined function)
  2456.  
  2457. FN name [(variable list)]
  2458.  
  2459. FN executes a function defined using DEF FN. Example:
  2460.  
  2461.         Def Fn Asin(X)=90-Acos(X)
  2462.         Degree
  2463.         Print Fn Asin(0.5)
  2464.  
  2465. 10:SCREENS
  2466.  
  2467. The default screen
  2468. Whenever you run an AMOS Basic program a default screen is created as
  2469. screen zero. This forms a standard display which will be used for all
  2470. your normal drawing operations.
  2471.  
  2472.   The system defaults to a 16-colour screen with dimensions 320x200,
  2473. which can easily be altered from within your program. In addition, you
  2474. can also define up to seven further screen with power SCREEN OPEN
  2475. command.
  2476.  
  2477. Defining a screen
  2478.  
  2479.                       SCREEN OPEN (open a screen)
  2480.  
  2481. SCREEN OPEN n, w, h, nc, mode
  2482.  
  2483. SCREEN OPEN opens a screen, and reserves some memory it. The new screen
  2484. will now be used as the destination of all subsequent text and
  2485. graphical operations in your program.
  2486.  
  2487.   n is the identification number of the screen which is to be created
  2488. by this instruction. Possible values range from 0-7. If this screen
  2489. already exists, it will be totally replaced by your new definition.
  2490.  
  2491.   w holds the width of the screen in pixels. This is not limited to the
  2492. physical size of your display. It's perfectly lefal to define extra
  2493. large screens which may be manupulated using SCREEN OFFSET.
  2494.  
  2495.   h sets the height of your screen using the same system. Providing
  2496. you've enough memory, you can easily create screens which are much
  2497. larger than the visible screen area. These screens can be used in
  2498. conjunction with all the normal screen operations. So you can construct
  2499. your images off-screen, and scroll them into view with the SCREEN
  2500. OFFSET command.
  2501.  
  2502.   nc requests the number of colours required for the new screen. The
  2503. range of available colours varies from 2 to 64 (EHB). You can also
  2504. access the Amiga's special HAM mode with a value of 4096.
  2505.  
  2506.   "mode" allows you to choose the width of the individual points on the
  2507. screen. The Amiga supports screen widths of either 320 or 640 pixels.
  2508. You can select the required width by setting "mode" either LOWRES (0)
  2509. or HIRES ($8000).
  2510.  
  2511.   Here's a list of the possible screen options along with an indication
  2512. of the amount of memory they consume.
  2513.  
  2514. RESOLUTIONS
  2515.  
  2516.            2     320 x 200     8 k  Paper=0 Pen=1 Crsr=1, no flash
  2517.                  640 x 200    16 k     "      "      "      "
  2518.            4     320 x 200    16 k  Paper=1 Pen=2 Crsr=3, flash=3
  2519.                  640 x 200    32 k     "      "      "      "
  2520.            8     320 x 200    24 k     "      "      "      "
  2521.                  640 x 200    48 k     "      "      "      "
  2522.           16     320 x 200    32 k  This is a default screen 0
  2523.                  640 x 200    64 k
  2524.           32     320 x 200    40 k
  2525.           64     320 x 200    48 k  Extra Half-Bright mode (EHB)
  2526.          4096    320 x 200    48 k   Hold and Modify mode  (HAM)
  2527.  
  2528. Note that the memory sizes in the table only apply to a standard
  2529. screen. If you create taller of wider screens, the amount of memory is
  2530. consumed will obviously be considerable greater. Screen zero is
  2531. equivalent to:
  2532.  
  2533.         SCREEN OPEN 0,320,200,16,Lowres
  2534.  
  2535.                      SCREEN CLOSE (erase a screen)
  2536.  
  2537. SCREEN CLOSE n
  2538.  
  2539. SCREEN CLOSE deletes screen number n, and frees the memory for use.
  2540.  
  2541.                 AUTO VIEW ON/OFF (control viewing mode)
  2542.  
  2543. AUTO VIEW OFF
  2544.  
  2545. WHen you open a screen using SCREEN OPEN the new screen is usualyy
  2546. displayed immediately. This can be very incovenient during the
  2547. initialisation stages of your programs.
  2548.  
  2549.   The AUTO VIEW OFF command provides you with full control over the
  2550. updating process. It turns off the automatic display system copletely.
  2551. You can then update the screen display at a convenient point in your
  2552. program using the VIEW instruction.
  2553.  
  2554.   AUTO VIEW ON  activates automatic screen updating.
  2555.  
  2556.                  DEFAULT (reset screen to its default)
  2557.  
  2558. DEFAULT
  2559.  
  2560. Closes all current open screens and restores the display back to its
  2561. original default setting. Example:
  2562.  
  2563.         Load Iff "AMOS_DATA:IFF/Amospic.IFF",0
  2564.         Wait Key
  2565.         Defaul
  2566.  
  2567.               VIEW (display the current screen settings)
  2568.  
  2569. VIEW
  2570.  
  2571. Displays any changes to the current screen settings at the next
  2572. vertical blank period. You only have to use this command when AUTOVIEW
  2573. is OFF.
  2574.  
  2575. Special screen modes
  2576. The colour of every point on the screen is determined by a value held
  2577. in one of the Amiga's 32 colour registers. Each register can be loaded
  2578. from a selection of 4096 different colours.
  2579.  
  2580.   Although 32 colours may seem rather a lot, particularly by ST
  2581. standards, it wasn't enough for the Amiga's designers. The easiest
  2582. solution would have been to increase the number of colour registers,
  2583. but this was quickly ruled out from reasons of cost.
  2584.  
  2585.   Instead, they invented two special graphics modes which cleveroly
  2586. exploited the existing registers to increase the maximum number of
  2587. colours on the screen.
  2588.  
  2589.   You've propably encountered these modes already. They're the infamous
  2590. Extra Half Bright and HAM modes. AMOS Basic provides full support for
  2591. both HAM and Half Bright modes. Here's a brief explanation.
  2592.  
  2593. Extra Half Bright mode (EHB)
  2594. Doubles the maximum colours on the screen to a grand total of 64. It
  2595. works by generating two colours for each of the 32 possible colour
  2596. registers.
  2597.  
  2598.   The first 32 colours load the colour value directly from one of the
  2599. registers. Each register contains a value between 0 and 4095 which sets
  2600. the precise shade of the final colour.
  2601.  
  2602.   The second group of colours, with numbers from 32 to 63, take one of
  2603. the previous registers and divide its contents by two. This produces 32
  2604. extra colours which are exactly half as bright as the normal colour
  2605. registers.
  2606.  
  2607.   In order to exploit EHB mode to the full, it's necessary to load the
  2608. 32 registers with the brightest shades in your palette. This will
  2609. automatically generate a list of intermediate tones in colours 32-63.
  2610. Aside from t
  2611.  
  2612. Hold and Modigy mode (HAM)
  2613. The Amiga's hardware currently limits you to a maximum of six bit
  2614. planes per screen. This allows you to display up to 64 different
  2615. colours on the screen at once. If you wanted to display a photograph
  2616. though, you'd require hunderds or even thousands of colours on the
  2617. screen.
  2618.  
  2619.   This was the problem faced by Jay Miner when he was designing the
  2620. Amiga's display system. His solution was to exploit a trick which has
  2621. been known by artists for centuries. If a professional aritst had to
  2622. take every conceivable colour on an assignment, he would be faced with
  2623. an impossible task. It's therefore common parctice to mix the exact
  2624. shade on the spot, out of a small set of basic colours. This provides
  2625. millions of potential shades, without the need to carry several large
  2626. lorry loads worth of paint. The same technique can also be applied to a
  2627. computer screen. Instead of specifying each colour individually, you
  2628. can take an existing colour and modify it slightly. This increases the
  2629. number of available colours tremendously, and forms the basis of the
  2630. Amiga's powerfl Hold And Modify mode.
  2631.  
  2632.   Each colour value on the Amiga is created from a mixture of the three
  2633. separate components. These determine the relative strength of the
  2634. primary colours Red, Green and Blue in the final colour. Possible
  2635. intenses range from 0 to 15.
  2636.  
  2637.   Ham mode splits the Amiga's colour values into four separate groups:
  2638.  
  2639.  * Colour registers 0-15: The first 16 colour take a value directly
  2640.                           from a colour register. These colours are
  2641.             treadted just like those on a standard 16 colour screen.
  2642.  
  2643.  * Red components   16-31: However, if a point is set to a colour
  2644.                            number in the range 16 to 31, the colour
  2645.             value is loaded from the pixel to its immediate left.
  2646.             The Red component of this colour is now replaced with a
  2647.             value from 0 to 15 which is calculated from the formula:
  2648.  
  2649.             Intensity=Colour index - 16
  2650.  
  2651.  * Green components 32-47: Similarly, a colour number from 32 to 47
  2652.                            takes the current shade, and changes the
  2653.             green component. The intensity of this component is set
  2654.             to a value of colour - 32.
  2655.  
  2656.  * Blue components  48-63: These colour numbers grab the colour value
  2657.                            from the point on the left of the current
  2658.             pixel, and load a new blue component from your colour
  2659.             number like so:
  2660.  
  2661.             Intensity = Colour Index - 48
  2662.  
  2663. The colour of a particular point therefore depends on the colours of
  2664. all the points to the left of it. This allows you to create smooth
  2665. gradiations of colour which are ideal for flesh tones. However, you
  2666. can't choose the colour of each point on the screen independently. In
  2667. practice, it takes a maximum of three pixles to shift from one colour
  2668. to another.
  2669.  
  2670.   When the Amiga was first released, Ham initially was regarded as
  2671. little more than curiosity. Nowadays, the situation is very different,
  2672. with the advent of excellent Ham graphics packages such as Photon
  2673. Paint.
  2674.  
  2675.   AMOS allows you to perform the full range text and graphics
  2676. operations directly on to a Ham screen. EXAMPLE 10.1 provides you with
  2677. a simple example of how you can generate an entire screen in just a few
  2678. lines of Basic code.
  2679.  
  2680.   Another point to consider, is that Ham screens are manipulated using
  2681. the normal SCREEN DISPLAY and SCREEN OFFSET commands. Here are some
  2682. simple guidelines to their use:
  2683.  
  2684.  * The first point in each horizontal line should be set to a colour
  2685.    number from 0 to 15. This will serve as the starting colour for all
  2686.    the shades on the current line.
  2687.  
  2688.  * Don't attempt to subject your Ham screens to horizontal scrolling.
  2689.    If you try to scroll one of these screens, you'll get colour fringes
  2690.    at the sides of your picture. These are generated by the changes in
  2691.    the starting colours for each line. There are no such restrictions
  2692.    to vertical scrolling.
  2693.  
  2694.  * Fringing effects can also be produced by SCREEN COPY. The solution
  2695.    is to ensure that the border of your zone is drawn using a colour
  2696.    from 0 to 15. This will ensure that your Ham screens will be redrawn
  2697.    at their new position with their original colours.
  2698.  
  2699. Loading a screen
  2700.  
  2701.               LOAD IFF (load an IFF screen from the disc)
  2702.  
  2703. LOAD IFF "filename"[,screen]
  2704.  
  2705. Loads an IFF format picture from the disc. "Screen" indicates the
  2706. number of the screen which is to be loaded with your picture. This
  2707. screen will be opened automatically for your use, if it didn't exist.
  2708. Anything already inside your screen will be totally erased.
  2709.  
  2710.   To load the picture into the present screen, omit the "screen"
  2711. parameter altogether.
  2712.  
  2713.   Example:
  2714.  
  2715.   Load Iff "AMOS_DATA:IFF/AMOSPIC.IFF",1
  2716.  
  2717. Saving a screen
  2718.  
  2719.                      SAVE IFF (save an IFF scree)
  2720.  
  2721. SAVE IFF "filename"[,compression]
  2722.  
  2723. Saves the current screen as an IFF picture file on the disc.
  2724. "compression" is a flag which allows you to choose whether your file
  2725. will be compacted before it's saved. A value of one specifies that the
  2726. standard file compressiong system is to be employed and zero saves the
  2727. picture as it stands. As a default all AMOS screens are compressed.
  2728.  
  2729.   SAVE IFF automatically appends a small IFF "chunck" to your picture
  2730. file. This stores the present screen settings including SCREEN DISPLAY,
  2731. SCREEN OFFSET and SCREEN HIDE/SHOW. When you load this file back into
  2732. AMOS Basic it will be returned to exactly its original condition. This
  2733. extra IFF data will be completely ignored by external graphics packages
  2734. such as DPaint 3.
  2735.  
  2736.   Note that it's possible to save double buffered or dual playfield
  2737. screens with this command.
  2738.  
  2739. Moving a screen
  2740.  
  2741.                   SCREEN DISPLAY (position a screen)
  2742.  
  2743. SCREEN DISPLAY n [, x, y, w, h]
  2744.  
  2745. Once you have defined your screen with SCREEN OPEN, you'll need to
  2746. position it on your screen. Unlike most other computers, the Amiga is
  2747. capable of displaying a picture anywhere you like on the TV screen.
  2748. This can be easily exploited to produce amazing "bouncing" screen
  2749. effects. With AMOS Basic, it's even possible to perform these
  2750. animations using interrupts (see AMAL).
  2751.  
  2752.   Another aplication is to overlay several screens alongside each
  2753. other. This allows you to create your display out of a combination of
  2754. different screen modes.
  2755.  
  2756.   "n" indicates the number of the screen to be positioned. "x" and "y"
  2757. specify the location of the screen in hardware coordinates.
  2758.  
  2759.   The x coordinates of a screen can range from 0 to 448 and are
  2760. automatically rounded down to the nearest 16-pixel boundary. Only the
  2761. positions between 112 and 448 actually visible on your TV though, and
  2762. you are strongly advised to avoid using an x coordinate below 112.
  2763.  
  2764.   The y coordinates of your screen can range between 0 and 312. The
  2765. visible range will largely depend on your TV or monitor, but you'll
  2766. propably find that coordinates between 30 and 300 are satisfactory for
  2767. the majority of systems.
  2768.  
  2769.   At the time of writing, there appears to be a minor bug in the
  2770. Amiga's HAM mode. These pictures cannot be displayed with a Y
  2771. coordinate of exactly 256. So set your coordinates to intermediate
  2772. values such as 255 or 257 instead. We're not sure if it's a hardware or
  2773. software fault yet but it won't restrict you by any means.
  2774.  
  2775.   "w" holds the width of your screen in pixels. If this is different
  2776. from the original setting, only a part of your image will be shown,
  2777. starting from the top left corner of the display. Like the x
  2778. coordinates, the screen width will be rounded to the nearest 16 pixel
  2779. boundary.
  2780.  
  2781.   Similarly, "h" sets the apparent height of the screen. Changing this
  2782. value will reduce the depth of your image.
  2783.  
  2784.   Generally SCREEN OPEN will automatically select the display position
  2785. for you using a standard setting in the AMOS configuration file. If a
  2786. screen is larger than the display then AMOS sets the screen into
  2787. overscan.
  2788.  
  2789.   SCREEN DISPLAY provides you with a simple way of changing these
  2790. values from the default. Any of the parameters x,y,h and w may be
  2791. omitted as appropriate. The unused values will be automatically
  2792. assigned to the default settings, and should be separated by commas.
  2793.  
  2794.         Screen Display 0,112,45,, : Rem position the screen at 112,45.
  2795.  
  2796. When you are positioning your screens, try to ensure that the screen
  2797. starts at the left of the display and ends towards the right. This is
  2798. essential if the Amiga's hardware is to interpret your screen
  2799. correctly. In practice, you may need to experiment a little to get the
  2800. precise effect you want. Fortunately, the worst that can happen is that
  2801. you'll get a silly looking display. The Amiga won't crash if you make a
  2802. mistake. here are some guidelines to help you along:
  2803.  
  2804.  * Only a single screen can be displayed on each horizontal line.
  2805.    However, you can safely place several screens on top of each other.
  2806.    All will be well, providing only one of the screens visible.
  2807.  
  2808.  * There will always be a one pixel thick "dead zone" between each pair
  2809.    of screens. This is generated by the copper list and is completely
  2810.    unavoidable. The dead zone will be noticeable whenever you move a
  2811.    sprite between the screens. As an example, try moving the mouse
  2812.    pointer from the editor window to the menu line. You should see a
  2813.    small black line through your mouse pointer at the border between
  2814.    the two screens.
  2815.  
  2816.                        SCREEN OFFSET (hardware scrolling)
  2817.  
  2818. SCREEN OFFSET n,x,y
  2819.  
  2820. The Amiga's display is not just limited to the visible dimensios of
  2821. your TV screen. There's absolutely nothing stopping you from generating
  2822. images which are much larger than the actual screen. It's obviously not
  2823. possible to display such pictures in their entirety, but you can easily
  2824. view a section of your image using the SCREEN OFFSET command.
  2825.  
  2826.   "n" is the number of the screen to be displayed. x,y measure the
  2827. offset from the top left hand corner of the screen to the starting
  2828. point for your display. x and y are specified in units of a single
  2829. pixel, so there's nothing stopping you from generating some
  2830. delightfully smooth scrolls.
  2831.  
  2832.   You can also use negative offsets with this instruction, allowing you
  2833. to display any part of the Amiga's memory on the screen. See
  2834. EXAMPLE 10.2 for a full demonstration of this command.
  2835.  
  2836. Screen control commands
  2837.  
  2838.                      SCREEN CLONE (clone a screen)
  2839.  
  2840. SCREEN CLONE n
  2841.  
  2842. The SCREEN CLONE command assigns a second version of the current screen
  2843. to screen number n. This clone uses exactly the same memory area as the
  2844. original screen.
  2845.  
  2846.   Normally, the cloned screen is displayed at the same place as its
  2847. parent. However it can be manupulated separately using any of the
  2848. normal screen operations such as SCREEN DISPLAY and SCREEN OFFSET.
  2849.  
  2850.   Since there's only a *single* copy of the original screen data in
  2851. memory, you can't access a clone with the SCREEN command. You'll get an
  2852. "illegal screen parameter" error if you rty. Another point to consider
  2853. is that any colour flash sequences you've set up on the original screen
  2854. will NOT be copied during the cloning operation. See EXAMPLE 10.3.
  2855. Notice the use of the WAIT VBL command. This ensures that the clone is
  2856. repositioned off-screen and keeps the movements running smoothly.
  2857.  
  2858.   If you experiment with SCREEN CLONE, you'll quickly find that there's
  2859. a real limit to the amount of movement you can perform without spoiling
  2860. the effect completely. Even something as trivial as an extra
  2861. calculation to your movement routine can often introduce an
  2862. unacceptable delay into your animations.
  2863.  
  2864.   The screen display can also be adjusted directrly from the AMAL
  2865. animation language. This is capable of animating large numbers of
  2866. screens smoothly and easily. See EXAMPLE 10.4 for a demonstration.
  2867.  
  2868.                   DUAL PLAYFIELD (combine two screens
  2869.                          into dual playfield)
  2870.  
  2871. DUAL PLAYFIELD screen1, screen2
  2872.  
  2873. The Amiga's dual playfield mode allows you to display two complete
  2874. screens simultaneously at the same x and y coordinates. It's almost as
  2875. if you'd drawn eaxh screen on cellophane and overlayed them on top of
  2876. each other. Each screen can be manipulated totally independently. You
  2877. can exploit this to produce a smooth parallax effect which is ideal for
  2878. screen scrolling games such as Silkworm.
  2879.  
  2880.   The two components of a dual playfield are treated just like any
  2881. other AMOS screen and can be written to in the normal way. They can
  2882. even be animated within AMAL or double buffered.
  2883.  
  2884.   "screen1" and "screen2" refer to screens which have been previously
  2885. defined with the SCREEN OPEN command. Only certain screen combinations
  2886. are acceptable. Both screens MUST use the same resolution, as it's
  2887. illegal to use hires(meaning actually MedRes) and lowres in the same
  2888. playfield.
  2889.  
  2890. Here is a list of the possibilities
  2891.  
  2892.         Screen 1    Screen 2    Notes
  2893.  
  2894.         #of colours #of colours
  2895.             2           2
  2896.             4           2
  2897.             4           4
  2898.             8           4       LowRes only
  2899.             8           8       LowRes only
  2900.  
  2901. Although the colour ranges are predefined, the sizes of the two screens
  2902. can be completely different. By creating a background screen which is
  2903. larger than the foreground you can create a delightfully realistic
  2904. parallax effect.
  2905.  
  2906.   The colours of these screens are all taken from the palette of
  2907. screen1 with colour zero being treated as transparent.
  2908.  
  2909.         Screen  Colour indexes (from screen 1)
  2910.           1       0 - 7
  2911.           2       8 - 15
  2912.  
  2913. When you are drawing to the second screen, AMOS Basic will
  2914. automatically convert your colour index to the appropriate number
  2915. before using it. So INK 2 will use colour nine from the first palette.
  2916.  
  2917.   This conversion process does not apply to the assignment statements
  2918. such as COLOUR or PALETTE. It's important to remember this when you are
  2919. changing the colour settings, otherwise your new colours will not be
  2920. reflected on the actual screen. Always make "screen1" the current
  2921. screen before changing your colour assignments.
  2922.  
  2923. There are a couple of important opints which you must be aware of
  2924. before setting up a dual playfield screen:
  2925.  
  2926.    * The screen offsets for both screens must never be set to zero.
  2927.    * If you set a dual playfield screen up and then want to position
  2928.       it with SCREEN OFFSET be sure to specify dual screen 1 not the
  2929.       second.
  2930.  
  2931. DUAL PLAYFIELD is an extremely powerful instruction. A full
  2932. demostration can be found in EXAMPLE 10.5.
  2933.  
  2934.         DUAL PRIORITY (choose order of dual playfield screens)
  2935.  
  2936. DUAL PRIORITY screen1,screen2
  2937.  
  2938. The first screen of a dual playfield is normally displayed directrly
  2939. over the second. The DUAL PRIORITY command allows you to change this
  2940. order around so that screen2 appears in front if screen1
  2941.  
  2942.   WARNING! This instruction only changes the order of the display. It
  2943. has *NO* effect on the screen organization. The first screen in the
  2944. dual playfield list should therefore still be used for all colour
  2945. assignments and with SCREEN DISPLAY.
  2946.  
  2947.                       SCREEN (set current screen)
  2948.  
  2949. SCREEN n
  2950.  
  2951. The SCREEN command allows you to direct all graphical and text
  2952. operations to screen number n.
  2953.  
  2954.                   =SCREEN (get the current screen #)
  2955.  
  2956. s=SCREEN
  2957.  
  2958. Returns the number of the currently active screen.
  2959.  
  2960.           SCREEN TO FRONT (moves screen to front of display)
  2961.  
  2962. SCREEN TO FRONT [s]
  2963.  
  2964. This instruction moves screen "s" to the front of the TV display. If
  2965. the parameter is omitted, then the current screen will be used instead.
  2966.  
  2967. Note: if the AUTOVIEW system has been turned off, you'll need to call
  2968. the VIEW command before the effect will be visible on the screen.
  2969.  
  2970.             SCREEN TO BACK (move screen to back of display)
  2971.  
  2972. SCREEN TO BACK [n]
  2973.  
  2974. SCREEN TO BACK moves a screen to the background of your display. If
  2975. there is another screen at the same coordinate this will now be
  2976. displayed in front of the selected screen.
  2977.  
  2978.                 SCREEN HIDE (temporarily hide a screen)
  2979.  
  2980. SCREEN HIDE [n]
  2981.  
  2982. Removes a selected screen from view copletely. This screen can be
  2983. redisplayed using a call to SCREEN SHOW. If n is omitted, this
  2984. instruction will hide the current screen.
  2985.  
  2986.                     SCREEN SHOW (restore a screen)
  2987.  
  2988. SCREEN SHOW [n]
  2989.  
  2990. Screen SHOW returns a screen onto the display after it has been hidden
  2991. with the SCREEN HIDE command.
  2992.  
  2993.                =SCREEN HEIGHT (return height of screen)
  2994.  
  2995. h=SCREEN HEIGHT [n]
  2996.  
  2997. Returns the height of an AMOS screen. If you don't include the
  2998. parameter n, the height will be returned for the current screen.
  2999.  
  3000.               =SCREEN WIDTH (return the  width of screen)
  3001.  
  3002. w=SCREEN WIDTH [n]
  3003.  
  3004. SCREEN WIDTH retrieves the width of either the current screen or screen
  3005. number n. Example:
  3006.  
  3007.         Print Screen Width
  3008.  
  3009.              =SCREEN COLOUR (return the number of colours)
  3010.  
  3011. c=SCREEN COLOUR
  3012.  
  3013. Returns the maximum numbers of colours in the currently active screen.
  3014.  
  3015.          =SCIN (returns screen number at a selected position)
  3016.  
  3017. s=SCIN(x,y)
  3018.  
  3019. Returns the number of screen which is underneath the *hardware*
  3020. coordinates x,y. If this screen does not exist, then s will be loaded
  3021. with a negative value (null).
  3022.  
  3023.   SCIN is normally used in conjuction with the X MOUSE and Y MOUSE
  3024. functions to check whether the mouse cursor has entered a particular
  3025. screen. Example:
  3026.  
  3027.         Print Scin(X Mouse, Y Mouse)
  3028.  
  3029. Defining the screen colours
  3030.  
  3031.           DEFAULT PALETTE (load screen with standard palette)
  3032.  
  3033. DEFAULT PALETTE c1,c2,c3,,,c6,,-> up to 32 colours
  3034.  
  3035. This command simplifies the process of opening many screens with the
  3036. same palette. It defines a list of colours which will be used for all
  3037. subsequent screens which you create with the SCREEN OPEN instruction.
  3038. As usual, the allowable colour values range from $000 to $FFF.
  3039.  
  3040.               GET PALETTE (set the palette from a screen)
  3041.  
  3042. GET PALETTE n [,mask]
  3043.  
  3044. The GET PALETTE instruction copies the colours from screen n and loads
  3045. them into the current screen. This can be very useful when you're
  3046. moving information from one screen to another with SCREEN COPY, as it's
  3047. usually vital that both the source and destination screens share the
  3048. same colour settings.
  3049.  
  3050.   The optional "mask" parameter allows you to load just a selection of
  3051. the colours. See GET SPRITE PALETTE for full details of mask.
  3052.  
  3053. Clearing the screen
  3054.  
  3055.                         CLS (clear the screen)
  3056.  
  3057. CLS erases all or part of the current screen. There are three possible
  3058. formats of this command:
  3059.  
  3060.         CLS
  3061.  
  3062. Clears the current screen by filling it with colour zero and clears any
  3063. windows which may have been set up.
  3064.  
  3065.         CLS col
  3066.  
  3067. Fills your screen with colour col.
  3068.  
  3069.         CLS col,x1,y1 to x2,y2
  3070.  
  3071. Replaces the rectangular region at coordinates x1,y1,x2,y2 with a block
  3072. of colour col. Col can take any value from 0 to the max. number of
  3073. available colours. x1,y1,x2,y2 hold the coordinates for top left and
  3074. bottom right corners of the area to be cleared by this command.
  3075. Example:
  3076.  
  3077.         Cls : Circle 100,09,09 : Cls 1,50,50 To 150,150
  3078.  
  3079. Manipulating the contents of a screen
  3080.  
  3081.                SCREEN COPY (copy sections of the screen)
  3082.  
  3083. SCREEN COPY scr1 TO scr2
  3084.  
  3085. SCREEN COPY scr1,x1,y1,x2,y2 TO scr2,x3,y3 [,mode]
  3086.  
  3087. SCREEN COPY makes it possible to copy large sections of a screen from
  3088. one place to another at amazing speed.
  3089.  
  3090.   "scr1" holds the screen used as the source of your image. This can be
  3091. either a standard screen number or the number of a logical or physical
  3092. screen generated using the LOGIC and PHYSIC commands.
  3093.  
  3094.   "scr2" selects an optional destination screen into which this data
  3095. will be copied. If it's omitted, the area will be copied into the
  3096. current screen.
  3097.  
  3098.   x1,y1 and x2,y2 hold the dimensios of a rectangular source area, and
  3099. x3,y3 contain the coordinates of the destination. There are no
  3100. limitions to these coordinates whatsoever. Any parts of your image
  3101. which lie outside the current screen area will be automatically clipped
  3102. as appropriate.
  3103.  
  3104.   The optional "mode" parameter chooses which of the 255 possible
  3105. blitter modes will be used for your copying operation. These modes
  3106. determine how your source and destination areas will be combined
  3107. together on the screen. The mode is set using a bit-pattern in the
  3108. following format:
  3109.  
  3110.         Mode Bit        Source Bit      Destination Bit
  3111.            4                0                  0
  3112.            5                0                  1
  3113.            6                1                  0
  3114.            7                1                  1
  3115.  
  3116. Note that the bottom four bits in the pattern are not used by this
  3117. instruction and should always be set to zero.
  3118.  
  3119.   Each bit in "mode" represents a single combination of bits in the
  3120. source and destination areas. If a mode bit is set to one, then the
  3121. associated bit on the screen will also be loaded with a one, otherwise
  3122. the result will be zero.
  3123.  
  3124.   In order to select the correct drawing mode for you application, you
  3125. simply decide which combinations should result in a one and set the
  3126. appropriate bits in the "mode" parameter accordingly.
  3127.  
  3128.   Supposing you only wanted to set a bit on the screen if both the
  3129. source and destination bits were the same. You would look the table for
  3130. the points where your requirement was satisfied. This would produce the
  3131. following vaue for "mode":
  3132.  
  3133.         %10010000
  3134.  
  3135. If you're not familiar with binary notation, you may find this command
  3136. a little opaque. Rather than boring you silly with an explanation of
  3137. binay we'll now provide you with a detailed list of the more common
  3138. requirements along with the associated bit-maps.
  3139.  
  3140.         Mode    Effect                                  Bit-pattern
  3141.         REPLACE Replaces the destination with a direct   %11000000
  3142.                 copy of the source image (default).
  3143.         INVERT  Replaces the destination image by a      %00110000
  3144.                 reversed copy of the source image.
  3145.         AND     Combines the source and destination      %10000000
  3146.                 with a logical AND operation.
  3147.         OR      OR's the source with the destination     %11100000
  3148.                 image.
  3149.         XOR     Combines the source and destination      %01100000
  3150.                 area with an Exclusive OR.
  3151.  
  3152. Technically-minded users should note that SCREEN COPY combines the
  3153. source and destination using blitter areas B and C and that blitter
  3154. area A is not used by the system at all.
  3155.  
  3156. Scrolling the screen
  3157.  
  3158.                    DEF SCROLL (define a scroll zone)
  3159.  
  3160. DEF SCROLL n,x1,y1 to x2,y2,dx,dy
  3161.  
  3162. Allows you to define up to 16 different scrolling zones. Each of these
  3163. zones can be associated with a specific scrolling operation which is
  3164. determined by the variables dx and dy.
  3165.  
  3166.   n holds the number of the zone and can range from 1 to 16. x1,y1
  3167. refer to the coordinates of the top left-hand corner of the area to be
  3168. scrolled and x2,y2 to the point diagonally opposite.
  3169.  
  3170.   dx signifies the number of pixels the zone will be shifted to the
  3171. right in each operation. Negative numbers indicate that the scrolling
  3172. will be from right to left, and positive numbers from left to right.
  3173.  
  3174.   Similarly, dy holds the number of pixels the zone will be advanced up
  3175. or down during the scroll. In this case negative values of dy are used
  3176. to indicate an upward movement and positive values a downward motion.
  3177.  
  3178.                       SCROLL (scroll the screen)
  3179.  
  3180. SCROLL n
  3181.  
  3182. The SCROLL command scrolls the screen using the settings you have
  3183. specified with the DEF SCROLL instruction. n refers to the number of
  3184. the zone you wish to scroll.
  3185.  
  3186.         Load Iff "AMOS_DATA:IFF/Frog_Leap.IFF",2
  3187.         Def Scroll 1,0,0, to 320,200,1,0
  3188.         Do
  3189.           Scroll 1
  3190.         Loop
  3191.  
  3192. Larger examples can be found in EXAMPLE 10.7 and EXAMPLE 10.8. The
  3193. variable s holds the number of points the picture will be moved during
  3194. each SCROLL. Note the use of screen switching to improve the quality of
  3195. the motion.
  3196.  
  3197. Screen switching
  3198. In order to produce the smooth movement effects found in a computer
  3199. game, it's necessery to complete all the drawing operations within a
  3200. time span of no more than a 15th of a second. This represents a real
  3201. challenge for the fastest computer, and it's often impossible to
  3202. achieve even on the Amiga. If the animation is complex, your graphics
  3203. will therefore tend to flicker annoyingly as they are being drawn.
  3204.  
  3205.   Fortunately, there's a solution at hand which has been succesfully
  3206. exploited in the vast majority of modern arcade games. This *screen
  3207. switching* technique can easily generate flicker-free screen animation
  3208. using just a fraction of Amiga's computing power.
  3209.  
  3210.   The basic idea is extremely simple. Instead of constructing your
  3211. images on the actual screen, you perform all your drawing operations on
  3212. a separate logical screen, which is copletely invisible to the user.
  3213. This is distinct from the *physical screen* which is currently being
  3214. displayed on your TV. Once the graphics have been completed, you can
  3215. then swap the logical and physical screen to produce a smooth
  3216. transition between the two screen images. The old physical screen now
  3217. becomes the new logical screen, and is used to construct the next
  3218. picture in your sequence.
  3219.  
  3220.   At fist glance, this process looks pretty complicated, but it's all
  3221. performed automatically by the AMOS Basic DOUBLE BUFFER command. This
  3222. forces all drawing operations to be performed directly on the logical
  3223. screen without affecting the current display. All you need to do within
  3224. your program is to synchronise your drawing operations with the screen
  3225. switches. This can be achieved with the help of SCREEN SWAP
  3226. instruction.
  3227.  
  3228.           SCREEN SWAP (swap the logical and physical screens)
  3229.  
  3230. SCREEN SWAP [n]
  3231.  
  3232. SCREEN SWAP swaps the physical and logical screens. This enables you to
  3233. instananeously switch the physical display between the two screens.
  3234.  
  3235.   If you're using DOUBLE BUFFER, these screens will have been created
  3236. for you already. However, you will need to switch off the automatic
  3237. screen switching system with BOB UPDATE OFF, as otherwise the screens
  3238. will be swapped 50 times a second, and will interfere with your own
  3239. drawing operations. It's also necessary to kill the autoback feature
  3240. with AUTOBACK OFF. This normally copies your graphical operatoins onto
  3241. both physical and logical screens. It's useful when you wish to combine
  3242. simple graphics with moving bobs, but it destroys the effect of your
  3243. screen switching operations totally.
  3244.  
  3245.   As an illustration of the power of this command, have a look at the
  3246. programs EXAMPLE 10.9 and EXAMPLE 10.10.
  3247.  
  3248.                 =LOGBASE (return the address of part of
  3249.                       part of the logical screen)
  3250.  
  3251. address=LOGBASE(plane)
  3252.  
  3253. The LOGBASE function is aimed at expert programmers who wish to access
  3254. the Amiga's screen memory directly. "plane" referes one of the six
  3255. possible bit-planes which make up the current screen. After LOGBASE has
  3256. been called, "address" will contain either the address of the required
  3257. bit-plane, or zero if it doesn't exist.
  3258.  
  3259.                    =PHYSBASE (return the address of
  3260.                           the current screen)
  3261.  
  3262. address=PHYBASE
  3263.  
  3264. PHYBASE returns the address in memory of bit-plane number "plane" for
  3265. the current screen. If this plane does not exist, then a value of zero
  3266. will be returned by this function. Example:
  3267.  
  3268.         Loke Phybase(0),0 : Rem pokes a thin line directly onto the
  3269.                                 screen.
  3270.  
  3271.                      =PHYSIC (return identifier of
  3272.                          the physical screen)
  3273. =PHYSIC
  3274. =PHYSIC(s)
  3275.  
  3276. The PHYSIC function returns an identification number for the current
  3277. physical screen. This number allows you to directly access the physical
  3278. image which is being displayed by the double buffering system.
  3279.  
  3280.   The result of this function can be substituted for the screen number
  3281. in the ZOOM, APPEAR and SCREEN COPY commands.
  3282.  
  3283.   "s" is the number of an AMOS screen. If it's omitted, then the
  3284. present screen will be used instead. Don NOT confuse with the LOGBASE
  3285. function.
  3286.  
  3287.                      =LOGIC (return identifier of
  3288.                           the logical screen)
  3289. =LOGIC
  3290. =LOGIC(s)
  3291.  
  3292. Returns an identification number of a logical screen. This can be used
  3293. in conjunction with the SCREEN COPY, APPEAR and ZOOM commands to change
  3294. your image off-screen, without affecting the current display.
  3295.  
  3296. Screen synchronisation
  3297. Like most home computers the AMIGA uses a memory-mapped display. This
  3298. is a technical term for a concept you are almost certainly already
  3299. familiar with. Put simply, a memory-mapped display is one which uses
  3300. special hardware to convert en image stored in memory into a signal
  3301. which can be displayed to your TV screen. Whenever AMOS Basic accesses
  3302. the scren it does so through the medium of this screen memory.
  3303.  
  3304.   The screen display is updated by the hardware every 50th of a second.
  3305. Once a screen has been drawn, the electron beam turns off and returns
  3306. to the top left of the screen. This process is called the vertical
  3307. blank period VBL. At the same time, AMOS Basic performs a number of
  3308. important tasks, such as moving the sprites and switching the physical
  3309. screen address if it has changed. The actions of instructions such as
  3310. ANIM or SCREEN SWAP will therefore only be fully completed when the
  3311. screen is redrawn.
  3312.  
  3313.   Since a 50th of a second is a quite long time for AMOS Basic, this
  3314. can lead to a serious lack of coordination between your program and the
  3315. screen, which is especially noticeable in tight program loops. The best
  3316. way of avoiding this is difficulty, is to wait until the screen has
  3317. been updated before you execute the next Basic command.
  3318.  
  3319.                  WAIT VBL (wait for a vertical blank)
  3320.  
  3321. The WAIT WBL instruction halts the AMIGA until ne next vertical blank
  3322. period. It is commonly used after either a PUT BOB insturction or a
  3323. SCREEN SWAP
  3324.  
  3325. Special effects
  3326.  
  3327.                   APPEAR (fade between two pictures)
  3328.  
  3329. APPEAR source TO destination, effect [,pixels]
  3330.  
  3331. The APPEAR command enables you to produce fancy fades between the
  3332. "source" and "destination" screens. Source and destination are simply
  3333. the numbers of screens you've previously opened using SCREEN OPEN. You
  3334. can also substitute the LOGIC and PHYSIC functions in these positions
  3335. if required.
  3336.  
  3337.   "effect" determines the type of fade which will be produced by this
  3338. insturction. The size of this parameter can vary from 1 to the number
  3339. of pixels in you current screen.
  3340.  
  3341.   "pixels" specifies the number of points which are to affected.
  3342. Normally this value is set to the TOTAL screen area, but you can reduce
  3343. it to fade only a part of the screen. All screens are drawn in strict
  3344. order from the top of the screen to the bottom.
  3345.  
  3346.   The appearance of your fades will naturally vary depending on the
  3347. screen mode you are using. A program is provided in EXAMPLE 10.11  to
  3348. allow you to experiment with the various possibilities.
  3349.  
  3350.  
  3351.  
  3352.                     FADE (blend one or more colours
  3353.                          to new colour values)
  3354.  
  3355. FADE speed [,colour list]
  3356. FADE speed TO screen [,mask]
  3357.  
  3358. The FADE command allows you to smoothly change the entire palette from
  3359. one set of colours to another. This can be used to generate
  3360. professional-looking fade effects for your loading screens.
  3361.  
  3362.   The standard version of the instruction takes the current palette,
  3363. and slowly dissolves the screen colours to zero. Each colour value is
  3364. successively reduced by one until they reach zero. Example:
  3365.  
  3366.         Fade 15 : Wait 225
  3367.  
  3368.   "speed" is the number of vertical blank periods that must occur
  3369. before the next colour change is performed.
  3370.  
  3371.   Since the fadig effects are executed using interrupts, it's best to
  3372. wait until the operation has completely finished before proceeding to
  3373. the nexy Basic instruction. The time taken for the fade WAIT can be
  3374. calculated by the formula:
  3375.  
  3376.         wait value = fade speed * 15
  3377.  
  3378. Fade can be extended to generate a new palette directly from a list of
  3379. colour values.
  3380.  
  3381.         Fade 15,$100,$200,$200,$300
  3382.  
  3383. Any number of colours can be specified in this instruction, up to the
  3384. maximum allowed in the current graphics mode. Like most AMOS commands,
  3385. it's possible to omit selected parameters completely. These colours
  3386. will be totally unaffected fy the FADE command.
  3387.  
  3388.         Fade 15,,$100,$800,$F00
  3389.  
  3390. The most powerful form of FADE smoothly transforms the colours from the
  3391. current screen into a palette taken from an existing screen.
  3392.  
  3393.         Fade speed TO s [,mask]
  3394.  
  3395. The present colours are slowly converted into the palette of screen s.
  3396. It's also possible to load the palette from the sprite bank using the
  3397. same technique. Simply use a negative value for the screen number s.
  3398.  
  3399.   "mask" is a bit-pattern which specifies which colours should be
  3400. loaded. Each colour is associated with a single bit in this pattern
  3401. numbered from 0 to 15. If a bit is set to 1, then the relevant colour
  3402. will be changed. See EXAMPLE 10.12.
  3403.  
  3404.                  FLASH (set flashing colour sequence)
  3405.  
  3406. This command gives you the ability to periodically change the colour
  3407. assigned to any colour index. It does this with an interrupt similar to
  3408. that used by the sprite and the music instructions. The format of the
  3409. flash instruction is:
  3410.  
  3411.         FLASH index,"(colour,delay)(colour,delay)(colour,delay)..."
  3412.  
  3413.   "index" is the number of the colour which is to be animated. Delay is
  3414. set in units of a 50th of a second.
  3415.  
  3416.   Colour is stored in the standard RGB format (See COLOUR) for mode
  3417. details. The action of FLASH is to take each new colour from the list
  3418. in turn, and then load it into the index for a length of time
  3419. specified by the delay. When the end of this list is reached, the
  3420. entire sequence of colours is repeated from the start. Note that you
  3421. are only allows to use a max. of 16 colour changes in any one FLASH
  3422. instruction. Here is a small example:
  3423.  
  3424.         Flash 1,"(007,10)(000,10)"
  3425.  
  3426. This alternates colour number 1 between blue and black every 10/50th of
  3427. a second.
  3428.  
  3429.         FLASH OFF
  3430.  
  3431. Turns off the flashing. Note that on start-up, colour number 3 is
  3432. automatically assigned a flash sequence for use by the cursor. It's a
  3433. good idea to turn this off before loading any pictures from the disc.
  3434.  
  3435.                       SHIFT UP (colour rotation)
  3436.  
  3437. SHIFT UP delay,first,last,flag
  3438.  
  3439. The SHIFT UP command rotates the values held in the colour registers
  3440. from the "first" to "last". The "first" colour in the list is copied
  3441. into the second, and the second into the third, and so on, until the
  3442. "last" colour in the series is reached.
  3443.  
  3444.   Each AMOS screen can have its own unique set of colour animations.
  3445. Colour shifts can be used to create amazing hyperspace sequences
  3446. similar to those found in Captain Blood and Elite. Since these
  3447. animations are performed using interrupts, they can be executed while
  3448. your program is running, without affecting it in the slightest.
  3449.  
  3450.   "delay" is the time interval between each stage of the rotation,
  3451. measured in 50ths of a second.
  3452.  
  3453.   "flag" controls the type of rotation. If it's ste to one, the last
  3454. colour index in the list will be copied into the first, and the first
  3455. to the last. So the colours will rotate continuously on the screen.
  3456. When "flag" is set to zero, the contents of the first and last indexes
  3457. will be discarded, and the region between first and last will be
  3458. replaced by a copy of the first colour in the list. For example:
  3459.  
  3460.         SHIFT UP 100,1,15,1
  3461.  
  3462.         SHIFT UP 10,1,15,0
  3463.  
  3464.                      SHIFT DOWN (colour rotation)
  3465.  
  3466. This is similar to the SHIFT UP, except it rotates the colours in the
  3467. opposite direction.
  3468.  
  3469.          SHIFT OFF (stops col.rotation for the current screen)
  3470.  
  3471. SHIFT OFF
  3472.  
  3473. Immediately terminates all colour rotations produced by the SHIFT UP or
  3474. SHIFT DOWN instructions
  3475.  
  3476.                  SET RAINBOW (define a rainbow effect)
  3477.  
  3478. Defines an attractive rainbow effect which can be subsequently
  3479. displayed using the RAINBOW command. It works by changing the shade of
  3480. a colour according to a series of simple rules.
  3481.  
  3482.   "n" is the number of your rainbow. Possible values range from 0 to 3.
  3483. "colour" is a colour index which will be changed by the instruction.
  3484. This colour can be assigned a different value for each horizonal sreen
  3485. line (or scan line). Note that only colours 0-15 can be manipulated
  3486. using this system.
  3487.  
  3488.   "length" sets the size of table to store your colours. There's one
  3489. entry in this table for each colour value on the screen. The size of
  3490. this table can range from 16 to 54400. If "length" is less than the
  3491. physical height of your rainbow, then the colour pattern will be
  3492. repeated several times on the screen.
  3493.  
  3494.   The r$,g$,b$ command strings, progressibely change the intensities of
  3495. the red, green and blue components of your final colour. These values
  3496. are loaded into a special colour table. Each colour in the table
  3497. determines the appearance of a single horizontal scan line on the
  3498. screen.
  3499.  
  3500.   At the start of the rainbow, all the components in your colour are
  3501. initially loaded with a value of zero. This will be changed according
  3502. to the information held in the colour table.
  3503.  
  3504.   Any command string may be omitted if required, but you'll still have
  3505. to include the quotes and the commas in their expected positions.
  3506.  
  3507.   Each string can contain a whole list of commands. These will be
  3508. cycled continually to produce the final rainbow pattern. The format is:
  3509.  
  3510.         (n,step,count)
  3511.  
  3512. "n" sets the number of lintes to be assigned to a specific colour value
  3513. in the rainbow. Increasing this number will change the height of each
  3514. individual rainbow line.
  3515.  
  3516.   "step" holds a number to be added to the component. This number will
  3517. be used to generate the colour of the succeeding line on the screen. A
  3518. positive step will increase the intensity of colour component, and a
  3519. negative value will reduce it.
  3520.  
  3521.   Whenever a particular component exceeds the maximum of 15, a new
  3522. value will be calculated from the formula:
  3523.  
  3524.         new component = old component Mod 15
  3525.  
  3526. "count" is the number of times the current operation is to be repeated.
  3527. The best way to demonstrate this command is with an example:
  3528.  
  3529.         Set Rainbow 0,1,64,"(8,2,8)","",""
  3530.         Rainbow 0,56,1,255
  3531.         Wait Key
  3532.  
  3533. This creates a new rainbow with number zero using colour index one. As
  3534. you can see, SET RAINBOW only defines your rainbow. In order to display
  3535. it on the screen you need to make use of the RAINBOW command.
  3536.  
  3537.   The rainbow effects first loads your colour with a value of zero.
  3538. Every four scan-lines, the red component will be automatically
  3539. incremented by two. So the contents of colour zero will progressively
  3540. change from $000 to $E00. WHen the component exceeds the maximum of 15,
  3541. its remainder will be calculated, and the colour will be returned to
  3542. its starting point (zero). The pattern will now be repeated down the
  3543. screen.
  3544.  
  3545.   By defining a separate pattern for eaxh of the red, green and blue
  3546. components of your colour, you can easily generate some starling
  3547. patterns on the screen. Since each rainbow only uses a single colour
  3548. index, there's nothing stopping you from creating the same effects
  3549. using just two colour screens. These are ideal from the backgrounds of
  3550. an arcade game, as they consume very little memory. Example:
  3551.  
  3552.         Screen Open 0,320,256,2,Lowres
  3553.         Set Rainbow 0,1,128,"8,1,8)","(8,1,8)",""
  3554.         Rainbow 0,1,30,128
  3555.         Colour 1,0 : Curs Off : Cls 1 : Flash Off
  3556.         Locate 0,2 : Centre "Amos Basic" : Wait Key
  3557.  
  3558. For further demonstration of the superb effects that can be achieved
  3559. with this instruction load up EXAMPLE 10.13.
  3560.  
  3561.   Rainbows can also be animated using a powerful interrupt system. See
  3562. the section on AMAL for more details.
  3563.  
  3564.                     RAINBOW (create a rainbow effect)
  3565.  
  3566. RAINBOW n,base,y,h
  3567.  
  3568. Displays rainbow number n on the screen. If AUTOVIEW is set to OFF, the
  3569. rainbow will only appear when you next call the VIEW command.
  3570.  
  3571.   "base" is an offset in the first colour in the table you created with
  3572. SET RAINBOW. Changing this value will cycle the rainbow on the screen.
  3573.  
  3574.   y holds the vertical position of the rainbow in hardware coordinates.
  3575. The minimum calue for this coordinate is 40. If you attempt to use a
  3576. coordinate below this point, the rainbow will be displayed from line 40
  3577. onwards.
  3578.  
  3579.   h sets the height of your rainbow scan lines.
  3580.  
  3581.   Rainbows are totally compatible with the AMOS system including bobs
  3582. and sprits. However, don't attempt to rainbow a colour which is
  3583. currently being changed using the FLASH or SHIFT instructions, as this
  3584. will lead to unpredictable screen effects.
  3585.  
  3586.   Note that only a single rainbow effect can be displayed on a
  3587. particular scan line, even if they use different colours on the screen.
  3588.  
  3589.   Normally the rainbow with the highest screen position will be
  3590. displayed first. But if several rainbows start from the same scan line,
  3591. then the rainbow with the lowest identification number will be drawn in
  3592. front of the others.
  3593.  
  3594.                     =RAIN (change the colour of an
  3595.                        individual rainbow line)
  3596. RAIN(n,line)=c
  3597. c=RAIN(n,line)
  3598.  
  3599. This is the most powerful of all the rainbow creation commands, as it
  3600. allows to change the colour of an individual rainbow line to any value
  3601. you like.
  3602.  
  3603.   n is the number of the rainbow you wish to access. "line" is the
  3604. individual scan line to be changed. Example:
  3605.  
  3606.         Curs Off : Centre "Securitate Stinks!"
  3607.         Set Rainbow 1,1,4097,"","",""
  3608.         For Y=0 To 4095
  3609.           Rain(1,Y)=Y
  3610.         Next Y
  3611.         For C=0 to 4095-255
  3612.           Rainbow 1,C,40,255
  3613.         Next C
  3614.         Wait Key
  3615.  
  3616.                 ZOOM (magnify a section of the screen)
  3617.  
  3618. ZOOM source,x1,y1,x2,y2 TO dest,x3,y3,x4,y4
  3619.  
  3620. ZOOM is a simple instruction which allows you to change the size of any
  3621. rectangular region of the screen.
  3622.  
  3623.   "source" is the number of a screen from which your picture will be
  3624. taken. You can also use the LOGIC function to grab your image from the
  3625. appropriate logical screen. The rectangular area to be affected by this
  3626. instruction is entered using the coordinates x1,y1,x2,y2. "dest" holds
  3627. the destination screen for your image. Like the source, it can be
  3628. either a screen number, or a logical screen specified using LOGIC.
  3629.  
  3630.   The dimensios of this screen are taken from the cordinates x3,y3 and
  3631. x4,y4. These hold the dimensios of the rectangle into which the screen
  3632. segment will be compressed.
  3633.  
  3634.   The effect of this instruction depends on the relative sizes of the
  3635. source and destination rectanges. The source image is automatically
  3636. resized to fit exactly into the destination rectangle. So the same
  3637. instruction can be used to reduce or enlarge your images as required.
  3638.  
  3639.   See EXAMPLE 10.14 for a further demonstration.
  3640.  
  3641. Changing the copper list
  3642. The Amiga's co-processor (copper) provides total control over the
  3643. appearance of every line on your screen. This copper is a separate
  3644. processor with its own internal memory and unique set of instructions.
  3645. By programming the copper it's possible to freely generate a massive
  3646. variety of different screen effects. Normally the copper is managed
  3647. automatically by the AMOS system. Each of the available copper effects
  3648. can be performed directly from within AMOS Basic without the need to
  3649. indulge in complicated machine-level programming. In practive these
  3650. intructions will be more than sufficient for the vast majority of
  3651. applications.
  3652.  
  3653.   Obviously, no one can think of everything though. Expert programmers
  3654. may wish to access the copper directly to create their own special
  3655. screen modes.
  3656.  
  3657.   Be warned: The copper list is notoriously difficult to program, and
  3658. if you don't know precisely what you are doing, you'll almost certainly
  3659. crash your Amiga. Before embarking on your copper experiments for the
  3660. first time, you are therefore adviced to read one of the many reference
  3661. books on the subject. A good explanation can be found the "Amiga System
  3662. Programmers Guite" from Abacus.
  3663.  
  3664.              COPPER OFF (turn of the standard copper list)
  3665.  
  3666. COPPER OFF
  3667.  
  3668. Freezes the current AMOS copper list and turns off the screen display
  3669. copletely. You can now create your own display using a series of COP
  3670. MOVE and COP WAIT instructions.
  3671.  
  3672.   As a default, all user-defined copper lists are limited to a maximum
  3673. of 12k. On average, each copper instruction takes up two bytes. So
  3674. there's a space for around 6000 instructions. This may be increased if
  3675. required, using a special option from the CONFIG utility.
  3676.  
  3677.   Note that all copper instructions are written to a separate logical
  3678. list which is not displayed on the screen. This stops your program
  3679. corrupting the display while the copper list is being created. To
  3680. activate your new screen, you'll need to swap the physical and logical
  3681. lists around with the COP SWAP command.
  3682.  
  3683.   It's also important to generate your copper lists in strict order,
  3684. starting from the top left of your screen and progressing downward to
  3685. the bottom right. See EXAMPLE 10.15.
  3686.  
  3687.                   COPPER ON (restart the copper list)
  3688.  
  3689. COPPER ON
  3690.  
  3691. Restarts the AMOS copper list calculations and displays the current
  3692. AMOS screens.
  3693.  
  3694.                 COP MOVE (write a MOVE instruction into
  3695.                        the logical copper list)
  3696.  
  3697. COP MOVE addr,value
  3698.  
  3699. Generates a MOVE instruction in the logical copper list.
  3700.  
  3701.   "addr" is an address of a 16 bit register to be changed. This must
  3702. lie within the normal copper DATA ZONE ($7F-$1BE). "value" is a
  3703. word-sized integer to be loaded into the requested register.
  3704.  
  3705.                COP MOVEL (write a long MOVE instruction
  3706.                            into copper list)
  3707.  
  3708. COP MOVEL addr,value
  3709.  
  3710. This is identical to the COP MOVE, except that "addr" now refers to a
  3711. 32-bit copper register. "value" contains a long word intereger.
  3712.  
  3713.                   COP WAIT (copper WAIT instruction)
  3714.  
  3715. COP WAIT x,y [,x mask, y mask]
  3716.  
  3717. COP WAIT writes a WAIT instruction into your copper list. The copper
  3718. waits until the hardware coordinates x,y have been reached and returns
  3719. control to the main processor. Note that line 255 is automatically
  3720. managed by AMOS. So you don't have to worry about it at all.
  3721.  
  3722.   x mask and y mask are bit maps which allow you to wait until just a
  3723. certain combination of bits in the screen coordinates have been set. As
  3724. a default both masks are automatically assignet to $1FF.
  3725.  
  3726.                 COP RESET (reset copper list pointers)
  3727.  
  3728. COP RESET
  3729.  
  3730. Restores the address used by the next copper instruction to the start
  3731. of the copper list.
  3732.  
  3733.                   =COP LOGIC (address of copper list)
  3734.  
  3735. addr=COP LOGIC
  3736.  
  3737. This function returns the absolute address in memory of the logical
  3738. copper list. This allows you to poke your COPPER instructions directly
  3739. into the buffer, possibly using assembly language.
  3740.  
  3741. Hints and tips
  3742. * Before creating a screen with a user defined copper list, you'll
  3743.   first need to allocate some memory for the appropriate bit-maps.
  3744. Although you can use RESERVE for this purpose, it's much easier to
  3745. define a dummy screen with the SCREEN OPEN command instead. The copper
  3746. registers can be loaded with the addresses of the required bit-maps
  3747. using the LOGBASE function.
  3748.  
  3749.   You'll now be able to access your screen using all the standard AMOS
  3750. drawing features. In order to reserve the correct amount of memory, set
  3751. the number of colours to the MAXIMUM used in the new screen. This may
  3752. be a little wasteful, but simplifies things enormously.
  3753.  
  3754. * It's perfectly acceptable to combine user-defined screens with AMOS
  3755.   bobs. If you're using double buffering though, you'll have to define
  3756. a separate copper list for both the logical and physical screens. This
  3757. may be achieved using the following procedure;
  3758.  
  3759.   1 Define your copper list for the first screen
  3760.   2 Swap the logical and physical copper lists with COP SWAP
  3761.   3 Swap the physical and logical screens with SCREEN SWAP
  3762.   4 Define your copper list for the second screen
  3763.  
  3764. This will ensure that your bobs will updated correctly on your new
  3765. screens. All the normal AMOS commands can be used including AMAL.
  3766.  
  3767. NOW LOAD PART THREE.....
  3768.